package com.dqyt.khjc.service;

import com.alibaba.fastjson.JSON;
import com.dqyt.app.bean.*;
import com.dqyt.app.mongo.OtherInputDao;
import com.dqyt.app.mongo.ReportDao;
import com.dqyt.app.mongo.SampleDao;
import com.dqyt.khjc.bean.FaceData;
import com.dqyt.khjc.bean.OldMianZhao;
import com.dqyt.khjc.bean.OldQiPingBean;
import com.dqyt.khjc.bean.ResultMsg;
import com.dqyt.khjc.config.Config;
import com.dqyt.khjc.moudle.*;
import com.dqyt.khjc.utils.IpUtil;
import com.dqyt.khjc.utils.StringUtils;
import com.dqyt.khjc.utils.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.misc.BASE64Decoder;

import javax.servlet.http.HttpServletRequest;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.math.RoundingMode;
import java.sql.Time;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class FaceDataService {

    @Autowired
    private ReportDao reportDao;

    @Autowired
    private SampleDao mSampleDao;

    @Autowired
    private OtherInputDao otherInputDao;

    /**
     * 新增气瓶的报告
     *
     * @param request
     * @param data
     * @return
     */
    public ResultMsg uploadFaceData222(HttpServletRequest request, String data) {
        ResultMsg resultMsg = new ResultMsg();
        try {
            String redid = IpUtil.getIpAddr(request);
            // boolean isbaohan =  Arrays.asList(ReadConfig.redIps).contains(redid);
            //如果允许访问
            // if(isbaohan && !"".equals(data)){
            FaceData faceData = JSON.parseObject(data, FaceData.class);
            if (null == faceData) {
                resultMsg.setCode(ResultMsg.ERROR);
                return resultMsg;
            }
            //根据设备编号查询样品信息
            Sample sample = mSampleDao.getPcSampleBySbbh(faceData.getCcbh().trim());
            byte [] mimgArr = faceData.getTup();
            //本地的
            if(null != mimgArr){
                //System.out.println("准备开始了4444====="+faceData.getCcbh().trim());
                BASE64Decoder decoder = new BASE64Decoder();
                OutputStream os = new FileOutputStream(Config.UPLOADFOLDER2+"\\"+sample.bsbh+"_jx.png");
                os.write(mimgArr, 0, mimgArr.length);
                os.flush();
                os.close();
            }else{
            }
        } catch (Exception e) {

        }
        return resultMsg;
    }



    /**
     * 新增气瓶的报告
     *
     * @param request
     * @param data
     * @return
     */
    public ResultMsg uploadFaceData(HttpServletRequest request, String data) {
        ResultMsg resultMsg = new ResultMsg();
        try {
            OtherInput mOtherInput = otherInputDao.getOtherInput();
            String redid = IpUtil.getIpAddr(request);
            // boolean isbaohan =  Arrays.asList(ReadConfig.redIps).contains(redid);
            //如果允许访问
            // if(isbaohan && !"".equals(data)){
            FaceData faceData = JSON.parseObject(data, FaceData.class);
            if (null == faceData) {
                resultMsg.setCode(ResultMsg.ERROR);
                return resultMsg;
            }

            //根据设备编号查询样品信息
            Sample sample = mSampleDao.getPcSampleBySbbh2(faceData.getCcbh().trim());
            if (null != sample) {



                //如果当前的 样品没有分配 检验员 就不生成报告
                if(null ==sample.cylinders.jcrId || "".equals(sample.cylinders.jcrId)){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }
                if(sample.cylinders.sfjy==-1){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }

                //先 查询这条数据有没有生成 气瓶的报告
                Report reportOldQp = reportDao.getReportBybsbhAdType(sample.bsbh, 2);
                if (null != reportOldQp  && reportOldQp.sbbh.equals(faceData.getCcbh().trim())) {
                    //如果报告的时间大于已经存在的报告的时间
                    if (faceData.getTestTime() > reportOldQp.cylinders.bgCsrq) {
                        reportOldQp.bh = sample.bh;
                        //标识编号
                        reportOldQp.bsbh = sample.bsbh;
                        //任务单编号
                        reportOldQp.rwdbh = sample.rwdbh;
                        //设备编号
                        reportOldQp.sbbh = faceData.getCcbh();
                        //样品类型
                        reportOldQp.type = reportOldQp.BG_TYPE_FHQP;
                        reportOldQp.spType = sample.spType;
                        //设置短信的发送状态
                        reportOldQp.isSendSMS = 0;
                        //接收日期时间戳
                        reportOldQp.jsrqLong = sample.jsrqLong;
                        reportOldQp.pxzd = sample.pxzd;
                        //气瓶的状态

                        //如果小于等于%5 就是合格  大于%5就是不合格
                        if ("".equals(faceData.getBxl())) {
                            reportOldQp.reportStatue = 2;//不合格
                        } else {
                            double bxldb = Double.parseDouble(faceData.getBxl());
                            if (bxldb <= 5) {
                                reportOldQp.reportStatue = 1; //合格
                            } else {
                                reportOldQp.reportStatue = 2;//不合格
                            }
                        }
                        //报告的进展  待核验
                        reportOldQp.reportProgress = 1;

                        reportOldQp.zfzddhy = 0;
                        //子类状态先设置为0
                        reportOldQp.failedStart = 0;
                        reportOldQp.bsbhHrader = sample.bsbhHrader;
                        reportOldQp.erweima = sample.erweima;
                        reportOldQp.wtfId = sample.cylinders.wtfId;
                        reportOldQp.wtf = sample.cylinders.wtf;
                        reportOldQp.wtfIdChi = sample.wtfIdChi;
                        reportOldQp.wtfChi = sample.wtfChi;

                        reportOldQp.sjr = sample.sjr;

                        if("".equals(sample.zzcs)){
                            reportOldQp.zzcsId = sample.cylinders.zzcsId;
                            reportOldQp.zzcs = sample.cylinders.zzcs;
                        }else{
                            reportOldQp.zzcsId = sample.zzcsId;
                            reportOldQp.zzcs = sample.zzcs;
                        }
                        reportOldQp.jyyId = sample.cylinders.jcrId;


                        //设置气瓶的数据
                        CylindersReport cylindersReport = new CylindersReport();
                        cylindersReport.bh = sample.bh;
                        cylindersReport.wtfId = sample.cylinders.wtfId;
                        cylindersReport.wtf = sample.cylinders.wtf;
                        cylindersReport.ccbh = sample.cylinders.bh;
                        cylindersReport.xh = sample.cylinders.xh;
                        //共送检气瓶数
                        cylindersReport.gsjqps = 1;
                        //是否充气
                        cylindersReport.sfcq = sample.cylinders.sfcq;
                        //合格气瓶数/报废气瓶数
                        cylindersReport.hgqps = 1;
                        List<String> bb = new ArrayList<>();
                        bb.add(sample.sbbh);
                        cylindersReport.bhlist = bb;

                        cylindersReport.sjr = sample.cylinders.sjr;
                        cylindersReport.sjrId = sample.cylinders.sjrId;

                        cylindersReport.jyyId = sample.cylinders.jcrId;
                        cylindersReport.jyy = sample.cylinders.jcr;
                        cylindersReport.qmrId = sample.cylinders.jcrId;
                        cylindersReport.gcsrj = sample.cylinders.qpsrj;


                        //计算有效期
                        // 先获取到 送检日期    3年后的前一天
                        Date date2 = new Date(faceData.getTestTime());
                        reportOldQp.jyrqNian = TimeUtil.formatTime_Year(faceData.getTestTime());
                        reportOldQp.jyrqYue = TimeUtil.formatTime_Month(faceData.getTestTime());
                        cylindersReport.jyrq = TimeUtil.formatTime_tow(faceData.getTestTime());
                        cylindersReport.sjrq = sample.cylinders.sjri;
                        long year3 = TimeUtil.getDateBeforeYear(date2, 3);

                        String mc_scrq = "";
                        if(sample.cylinders.scrq.length() == 7){
                            mc_scrq =sample.cylinders.scrq+".01";
                        }else{
                            mc_scrq = sample.cylinders.scrq;
                        }

                        //得到15生产日期 15年后
                        long year15 = TimeUtil.getDateBeforeYear(TimeUtil.parsex(mc_scrq), 15);

                        if (year3 > year15) {
                            cylindersReport.yxrq = TimeUtil.formatTime_tow(year15);
                            reportOldQp.xcjyrq  = year15;
                        } else {
                            cylindersReport.yxrq = TimeUtil.formatTime_tow(year3);
                            reportOldQp.xcjyrq  = year3;
                        }
                        reportOldQp.setAddTime(TimeUtil.currentTimeMillis());
                        cylindersReport.jydw = "";


                        if(null!=mOtherInput){
                            cylindersReport.jydwsqh =mOtherInput.qp_jydwsqh;
                        }else{
                            //检验单位授权号 写死
                            cylindersReport.jydwsqh = Config.QP_JTDWSQH;
                        }

                        //查询样品信息的最警的样品
                        resultMsg.setCode(ResultMsg.SUCESS);
                        cylindersReport.isOldJiqi = 1;
                        byte [] mimgArr = faceData.getTup();
                        //保存在本地的路径写法
//                            if(null != mimgArr){
//                                //System.out.println("准备开始了4444====="+faceData.getCcbh().trim());
//                                BASE64Decoder decoder = new BASE64Decoder();
//                                OutputStream os = new FileOutputStream(Config.UPLOADFOLDER2+"\\"+sample.bsbh+"_jx.png");
//                                os.write(mimgArr, 0, mimgArr.length);
//                                os.flush();
//                                os.close();
//                                cylindersReport.hltUrl = "/fhqp/"+sample.bsbh+"_jx.png";
//                            }else{
//                                cylindersReport.hltUrl ="";
//                            }

                        //保存在服务器的路径写法
                        if(null != mimgArr){
                            BASE64Decoder decoder = new BASE64Decoder();
                            OutputStream os = new FileOutputStream(Config.UPLOADFOLDER2+"/"+sample.bsbh+"_jx.png");
                            os.write(mimgArr, 0, mimgArr.length);
                            os.flush();
                            os.close();
                            cylindersReport.hltUrl = "/fhqp/"+sample.bsbh+"_jx.png";
                        }else{
                            cylindersReport.hltUrl ="";
                        }


                        //设置报告测试时间
                        cylindersReport.bgCsrq =faceData.getTestTime();

                        reportOldQp.cylinders = cylindersReport;
                        reportDao.save(reportOldQp);
                    }
                }else{

                    //System.out.println("准备开始了11111====="+faceData.getCcbh().trim());

                    if(!"".equals(faceData.getCssj())){
                        //System.out.println("准备开始了22222====="+faceData.getCcbh().trim());
                        String syNian=faceData.getCssj().substring(0,4);
                        //如果送检日期的时间戳 减去 实验数据上面的时间戳  两者相差超过20天  就不用生成报告
                        int chazhi = TimeUtil.getOffectDay(sample.jsrqLong,faceData.getTestTime());
                        int difference = Math.abs(chazhi);
                        //如果差值小于20天 就生成数据
                        if(difference< Config.SJSC_DAY){
                            //System.out.println("准备开始了3333====="+faceData.getCcbh().trim());
                            //if(sample.jyrqNian.equals(syNian)){
                            Report report = new Report();
                            report.bh = sample.bh;
                            //标识编号
                            report.bsbh = sample.bsbh;
                            //任务单编号
                            report.rwdbh = sample.rwdbh;
                            //设备编号
                            report.sbbh = faceData.getCcbh();
                            //样品类型
                            report.type = report.BG_TYPE_FHQP;
                            report.spType = sample.spType;
                            //设置短信的发送状态
                            report.isSendSMS = 0;
                            //接收日期时间戳
                            report.jsrqLong = sample.jsrqLong;

                            report.pxzd = sample.pxzd;

                            //气瓶的状态
                            //如果小于等于%5 就是合格  大于%5就是不合格
                            if ("".equals(faceData.getBxl())) {
                                report.reportStatue = 2;//不合格
                            } else {
                                double bxldb = Double.parseDouble(faceData.getBxl());
                                if (bxldb <= 5) {
                                    report.reportStatue = 1; //合格
                                } else {
                                    report.reportStatue = 2;//不合格
                                }
                            }
                            //报告的进展  待核验
                            report.reportProgress = 1;

                            report.zfzddhy = 0;
                            //子类状态先设置为0
                            report.failedStart = 0;
                            report.bsbhHrader = sample.bsbhHrader;
                            report.erweima = sample.erweima;
                            report.wtfId = sample.cylinders.wtfId;
                            report.wtf = sample.cylinders.wtf;
                            report.wtfIdChi = sample.wtfIdChi;
                            report.wtfChi = sample.wtfChi;
                            report.sjr = sample.sjr;


                            if("".equals(sample.zzcs)){
                                report.zzcsId = sample.cylinders.zzcsId;
                                report.zzcs = sample.cylinders.zzcs;
                            }else{
                                report.zzcsId = sample.zzcsId;
                                report.zzcs = sample.zzcs;
                            }

                            report.jyyId = sample.cylinders.jcrId;
                            //设置气瓶的数据
                            CylindersReport cylindersReport = new CylindersReport();
                            cylindersReport.bh = sample.bh;
                            cylindersReport.wtfId = sample.cylinders.wtfId;
                            cylindersReport.wtf = sample.cylinders.wtf;
                            cylindersReport.ccbh = sample.cylinders.bh;
                            cylindersReport.xh = sample.cylinders.xh;
                            //是否充气
                            cylindersReport.sfcq =sample.cylinders.sfcq;
                            //共送检气瓶数
                            cylindersReport.gsjqps = 1;
                            //合格气瓶数/报废气瓶数
                            cylindersReport.hgqps = 1;
                            List<String> bb = new ArrayList<>();
                            bb.add(sample.sbbh);
                            cylindersReport.bhlist = bb;

                            cylindersReport.sjr = sample.cylinders.sjr;
                            cylindersReport.sjrId = sample.cylinders.sjrId;
                            cylindersReport.qmrId = sample.cylinders.jcrId;

                            cylindersReport.jyyId = sample.cylinders.jcrId;
                            cylindersReport.jyy = sample.cylinders.jcr;

                            cylindersReport.gcsrj = sample.cylinders.qpsrj;


                            //计算有效期
                            // 先获取到 送检日期    3年后的前一天

                            Date date2 = new Date(faceData.getTestTime());
                            report.jyrqNian = TimeUtil.formatTime_Year(faceData.getTestTime());
                            report.jyrqYue = TimeUtil.formatTime_Month(faceData.getTestTime());
                            cylindersReport.jyrq = TimeUtil.formatTime_tow(faceData.getTestTime());
                            cylindersReport.sjrq = sample.cylinders.sjri;
                            long year3 = TimeUtil.getDateBeforeYear(date2, 3);

                            String mc_scrq = "";
                            if(sample.cylinders.scrq.length() == 7){
                                mc_scrq =sample.cylinders.scrq+".01";
                            }else{
                                mc_scrq = sample.cylinders.scrq;
                            }
                            //得到15生产日期 15年后
                            long year15 = TimeUtil.getDateBeforeYear(TimeUtil.parsex(mc_scrq), 15);

                            if (year3 > year15) {
                                cylindersReport.yxrq = TimeUtil.formatTime_tow(year15);
                                report.xcjyrq  = year15;
                            } else {
                                cylindersReport.yxrq = TimeUtil.formatTime_tow(year3);
                                report.xcjyrq  = year3;
                            }
                            report.setAddTime(TimeUtil.currentTimeMillis());
                            cylindersReport.jydw = "";
                            if(null!=mOtherInput){
                                cylindersReport.jydwsqh =mOtherInput.qp_jydwsqh;
                            }else{
                                //检验单位授权号 写死
                                cylindersReport.jydwsqh = Config.QP_JTDWSQH;
                            }

                            //查询样品信息的最警的样品
                            resultMsg.setCode(ResultMsg.SUCESS);
                            cylindersReport.isOldJiqi = 1;
                            byte [] mimgArr = faceData.getTup();
                            //保存在本地的路径写法
//                            if(null != mimgArr){
//                                //System.out.println("准备开始了4444====="+faceData.getCcbh().trim());
//                                BASE64Decoder decoder = new BASE64Decoder();
//                                OutputStream os = new FileOutputStream(Config.UPLOADFOLDER2+"\\"+sample.bsbh+"_jx.png");
//                                os.write(mimgArr, 0, mimgArr.length);
//                                os.flush();
//                                os.close();
//                                cylindersReport.hltUrl = "/fhqp/"+sample.bsbh+"_jx.png";
//                            }else{
//                                cylindersReport.hltUrl ="";
//                            }

                            //保存在服务器的路径写法
                            if(null != mimgArr){
                                BASE64Decoder decoder = new BASE64Decoder();
                                OutputStream os = new FileOutputStream(Config.UPLOADFOLDER2+"/"+sample.bsbh+"_jx.png");
                                os.write(mimgArr, 0, mimgArr.length);
                                os.flush();
                                os.close();
                                cylindersReport.hltUrl = "/fhqp/"+sample.bsbh+"_jx.png";
                            }else{
                                cylindersReport.hltUrl ="";
                            }
                            //设置报告测试时间
                            cylindersReport.bgCsrq =faceData.getTestTime();
                            report.cylinders = cylindersReport;
                            //System.out.println("准备开始了55555====="+faceData.getCcbh().trim());
                            reportDao.save(report);
                            resultMsg.setCode(ResultMsg.SUCESS);
                        }
                    }
                }
            } else {
                resultMsg.setCode(ResultMsg.SUCESS);
            }

            // }else{
            //     resultMsg.setCode(ResultMsg.FAIL);
            // }
        } catch (Exception e) {

        }
        return resultMsg;
    }


    /**
     * 气瓶的数据（老机器）
     *
     * @param request
     * @param data
     */
    public ResultMsg uploaQpold(HttpServletRequest request, String data) {
        ResultMsg resultMsg = new ResultMsg();
        try {
            String redid = IpUtil.getIpAddr(request);
            //boolean isbaohan = Arrays.asList(ReadConfig.redIps).contains(redid);
            //如果允许访问
            //if(isbaohan && !"".equals(data)){
            OldQiPingBean oldQiPingBean = JSON.parseObject(data, OldQiPingBean.class);
            if (null == oldQiPingBean) {
                resultMsg.setCode(ResultMsg.ERROR);
                return resultMsg;
            }
            //根据设备编号查询样品信息
            Sample sample = mSampleDao.getPcSampleBySbbh2(oldQiPingBean.getCcbh().trim());
            if (null != sample) {
                //如果当前的 样品没有分配 检验员 就不生成报告
                if(null ==sample.cylinders.jcrId || "".equals(sample.cylinders.jcrId)){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }
                if(sample.cylinders.sfjy==-1){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }
                //先 查询这条数据有没有生成 气瓶的报告
                Report reportOldQp = reportDao.getReportBybsbhAdType(sample.bsbh, 2);

                if (null != reportOldQp  && reportOldQp.sbbh.equals(oldQiPingBean.getCcbh().trim())) {
                    //如果报告的时间大于已经存在的报告的时间
                    if (oldQiPingBean.getTestTime() > reportOldQp.cylinders.bgCsrq) {
                        reportOldQp.bh = sample.bh;
                        //标识编号
                        reportOldQp.bsbh = sample.bsbh;
                        //任务单编号
                        reportOldQp.rwdbh = sample.rwdbh;
                        //设备编号
                        reportOldQp.sbbh = oldQiPingBean.getCcbh().trim();
                        //样品类型
                        reportOldQp.type = reportOldQp.BG_TYPE_FHQP;
                        reportOldQp.spType = sample.spType;
                        //设置短信的发送状态
                        reportOldQp.isSendSMS = 0;
                        reportOldQp.pxzd = sample.pxzd;
                        //接收日期时间戳
                        reportOldQp.jsrqLong = sample.jsrqLong;

                        //气瓶的状态
                        //如果小于等于%5 就是合格  大于%5就是不合格
                        if ("".equals(oldQiPingBean.getBxl())) {
                            reportOldQp.reportStatue = 2;//不合格
                        } else {
                            double bxldb = Double.parseDouble(oldQiPingBean.getBxl());
                            if (bxldb <= 5) {
                                reportOldQp.reportStatue = 1; //合格
                            } else {
                                reportOldQp.reportStatue = 2;//不合格
                            }
                        }
                        //报告的进展  待核验
                        reportOldQp.reportProgress = 1;

                        reportOldQp.zfzddhy = 0;
                        //子类状态先设置为0
                        reportOldQp.failedStart = 0;
                        reportOldQp.bsbhHrader = sample.bsbhHrader;
                        reportOldQp.erweima = sample.erweima;
                        reportOldQp.wtfId = sample.cylinders.wtfId;
                        reportOldQp.wtf = sample.cylinders.wtf;
                        reportOldQp.wtfIdChi = sample.wtfIdChi;
                        reportOldQp.wtfChi = sample.wtfChi;

                        reportOldQp.sjr = sample.sjr;


                        if("".equals(sample.zzcs)){
                            reportOldQp.zzcsId = sample.cylinders.zzcsId;
                            reportOldQp.zzcs = sample.cylinders.zzcs;
                        }else{
                            reportOldQp.zzcsId = sample.zzcsId;
                            reportOldQp.zzcs = sample.zzcs;
                        }

                        reportOldQp.jyyId = sample.cylinders.jcrId;
                        //设置气瓶的数据
                        CylindersReport cylindersReport = new CylindersReport();
                        cylindersReport.bh = sample.bh;
                        cylindersReport.wtfId = sample.cylinders.wtfId;
                        cylindersReport.wtf = sample.cylinders.wtf;
                        cylindersReport.ccbh = sample.cylinders.bh;
                        cylindersReport.xh = sample.cylinders.xh;


                        //是否充气
                        cylindersReport.sfcq =sample.cylinders.sfcq;
                        //共送检气瓶数
                        cylindersReport.gsjqps = 1;
                        //合格气瓶数/报废气瓶数
                        cylindersReport.hgqps = 1;
                        List<String> bb = new ArrayList<>();
                        bb.add(sample.sbbh);
                        cylindersReport.bhlist = bb;

                        cylindersReport.sjr = sample.cylinders.sjr;
                        cylindersReport.sjrId = sample.cylinders.sjrId;
                        cylindersReport.jyyId = sample.cylinders.jcrId;
                        cylindersReport.jyy = sample.cylinders.jcr;
                        cylindersReport.qmrId = sample.cylinders.jcrId;

                        cylindersReport.gcsrj = sample.cylinders.qpsrj;
                        //计算有效期
                        // 先获取到 送检日期    3年后的前一天
                        Date date2 = new Date(oldQiPingBean.getTestTime());
                        reportOldQp.jyrqNian = TimeUtil.formatTime_Year(oldQiPingBean.getTestTime());
                        reportOldQp.jyrqYue = TimeUtil.formatTime_Month(oldQiPingBean.getTestTime());
                        cylindersReport.jyrq = TimeUtil.formatTime_tow(oldQiPingBean.getTestTime());
                        cylindersReport.sjrq = sample.cylinders.sjri;
                        long year3 = TimeUtil.getDateBeforeYear(date2, 3);

                        String mc_scrq = "";
                        if(sample.cylinders.scrq.length() == 7){
                            mc_scrq =sample.cylinders.scrq+".01";
                        }else{
                            mc_scrq = sample.cylinders.scrq;
                        }
                        //得到15生产日期 15年后
                        long year15 = TimeUtil.getDateBeforeYear(TimeUtil.parsex(mc_scrq), 15);

                        if (year3 > year15) {
                            cylindersReport.yxrq = TimeUtil.formatTime_tow(year15);
                            reportOldQp.xcjyrq = year15;
                        } else {
                            cylindersReport.yxrq = TimeUtil.formatTime_tow(year3);
                            reportOldQp.xcjyrq = year3;
                        }
                        reportOldQp.setAddTime(TimeUtil.currentTimeMillis());
                        cylindersReport.jydw = "";
                        OtherInput mOtherInput = otherInputDao.getOtherInput();
                        if(null!=mOtherInput){
                            cylindersReport.jydwsqh =mOtherInput.qp_jydwsqh;
                        }else{
                            //检验单位授权号 写死
                            cylindersReport.jydwsqh = Config.QP_JTDWSQH;
                        }
                        //查询样品信息的最警的样品
                        resultMsg.setCode(ResultMsg.SUCESS);
                        cylindersReport.isOldJiqi = 2;
                        byte [] mimgArr = oldQiPingBean.getTup();

                        //----------------------------需要大本地jar 和服务器jar
                        // if(null != mimgArr){
                        //     //保存图片到本地
                        //      boolean isok =  saveDocToLoacl2(oldQiPingBean,mimgArr,sample.bsbh+"_jx.doc",sample.bsbh);
                        //      if(isok){
                        //          cylindersReport.hltUrl = "/up/fhqp/"+sample.bsbh+"_jx.doc";
                        //      }else{
                        //          cylindersReport.hltUrl ="";
                        //     }
                        //  }else{
                        //      cylindersReport.hltUrl ="";
                        //  }


                        if(null != mimgArr){
                            oldQiPingBean.setTup(mimgArr);
                            BASE64Decoder decoder = new BASE64Decoder();
                            OutputStream os = new FileOutputStream(Config.UPLOADFOLDER2+"/"+sample.bsbh+"_jx.doc");
                            os.write(mimgArr, 0, mimgArr.length);
                            os.flush();
                            os.close();
                            cylindersReport.hltUrl = "/fhqp/"+sample.bsbh+"_jx.doc";
                        }else{
                            cylindersReport.hltUrl ="";
                        }



                        //设施报告的测试时间
                        cylindersReport.bgCsrq= oldQiPingBean.getTestTime();

                        reportOldQp.cylinders = cylindersReport;
                        reportDao.save(reportOldQp);
                    }
                }else{
                    if(!"".equals(oldQiPingBean.getSyjl_rq())){
                        //如果送检日期的时间戳 减去 实验数据上面的时间戳  两者相差超过20天  就不用生成报告
                        int chazhi = TimeUtil.getOffectDay(sample.jsrqLong,oldQiPingBean.getTestTime());
                        int difference = Math.abs(chazhi);
                        //如果差值小于20天 就生成数据
                        if(difference< Config.SJSC_DAY){
                            Report report = new Report();
                            report.bh = sample.bh;
                            //标识编号
                            report.bsbh = sample.bsbh;
                            //任务单编号
                            report.rwdbh = sample.rwdbh;
                            //设备编号
                            report.sbbh = oldQiPingBean.getCcbh().trim();
                            //样品类型
                            report.type = report.BG_TYPE_FHQP;
                            report.spType = sample.spType;
                            //设置短信的发送状态
                            report.isSendSMS = 0;
                            report.pxzd = sample.pxzd;
                            //接收日期时间戳
                            report.jsrqLong = sample.jsrqLong;

                            try{
                                String bnbn = oldQiPingBean.getBxl().trim();
                                //气瓶的状态
                                //如果小于等于%5 就是合格  大于%5就是不合格
                                if (null ==bnbn || "".equals(bnbn) || "Inf".equals(bnbn)) {
                                    report.reportStatue = 2;//不合格
                                } else {
                                    double bxldb = Double.parseDouble(bnbn);
                                    if (bxldb <= 5) {
                                        report.reportStatue = 1; //合格
                                    } else {
                                        report.reportStatue = 2;//不合格
                                    }
                                }
                            }catch (Exception e){
                                report.reportStatue = 2;//不合格
                            }
                            //报告的进展  待核验
                            report.reportProgress = 1;

                            report.zfzddhy = 0;
                            //子类状态先设置为0
                            report.failedStart = 0;
                            report.bsbhHrader = sample.bsbhHrader;
                            report.erweima = sample.erweima;
                            report.wtfId = sample.cylinders.wtfId;
                            report.wtf = sample.cylinders.wtf;
                            report.wtfIdChi = sample.wtfIdChi;
                            report.wtfChi = sample.wtfChi;
                            report.sjr = sample.sjr;

                            if("".equals(sample.zzcs)){
                                report.zzcsId = sample.cylinders.zzcsId;
                                report.zzcs = sample.cylinders.zzcs;
                            }else{
                                report.zzcsId = sample.zzcsId;
                                report.zzcs = sample.zzcs;
                            }
                            report.jyyId = sample.cylinders.jcrId;
                            //设置气瓶的数据
                            CylindersReport cylindersReport = new CylindersReport();
                            cylindersReport.bh = sample.bh;
                            cylindersReport.wtfId = sample.cylinders.wtfId;
                            cylindersReport.wtf = sample.cylinders.wtf;
                            cylindersReport.ccbh = sample.cylinders.bh;
                            cylindersReport.xh = sample.cylinders.xh;
                            //是否充气
                            cylindersReport.sfcq =sample.cylinders.sfcq;
                            //共送检气瓶数
                            cylindersReport.gsjqps = 1;
                            //合格气瓶数/报废气瓶数
                            cylindersReport.hgqps = 1;
                            List<String> bb = new ArrayList<>();
                            bb.add(sample.sbbh);
                            cylindersReport.bhlist = bb;

                            cylindersReport.sjr = sample.cylinders.sjr;
                            cylindersReport.sjrId = sample.cylinders.sjrId;
                            cylindersReport.jyyId = sample.cylinders.jcrId;
                            cylindersReport.jyy = sample.cylinders.jcr;
                            cylindersReport.qmrId = sample.cylinders.jcrId;

                            cylindersReport.gcsrj = sample.cylinders.qpsrj;
                            //计算有效期
                            // 先获取到 送检日期    3年后的前一天
                            Date date2 = new Date(oldQiPingBean.getTestTime());
                            report.jyrqNian = TimeUtil.formatTime_Year(oldQiPingBean.getTestTime());
                            report.jyrqYue = TimeUtil.formatTime_Month(oldQiPingBean.getTestTime());
                            cylindersReport.jyrq = TimeUtil.formatTime_tow(oldQiPingBean.getTestTime());
                            cylindersReport.sjrq = sample.cylinders.sjri;
                            long year3 = TimeUtil.getDateBeforeYear(date2, 3);

                            String mc_scrq = "";
                            if(sample.cylinders.scrq.length() == 7){
                                mc_scrq =sample.cylinders.scrq+".01";
                            }else{
                                mc_scrq = sample.cylinders.scrq;
                            }
                            //得到15生产日期 15年后
                            long year15 = TimeUtil.getDateBeforeYear(TimeUtil.parsex(mc_scrq), 15);

                            if (year3 > year15) {
                                cylindersReport.yxrq = TimeUtil.formatTime_tow(year15);
                                report.xcjyrq = year15;
                            } else {
                                cylindersReport.yxrq = TimeUtil.formatTime_tow(year3);
                                report.xcjyrq = year3;
                            }
                            report.setAddTime(TimeUtil.currentTimeMillis());
                            cylindersReport.jydw = "";
                            OtherInput mOtherInput = otherInputDao.getOtherInput();
                            if(null!=mOtherInput){
                                cylindersReport.jydwsqh =mOtherInput.qp_jydwsqh;
                            }else{
                                //检验单位授权号 写死
                                cylindersReport.jydwsqh = Config.QP_JTDWSQH;
                            }
                            //查询样品信息的最警的样品
                            resultMsg.setCode(ResultMsg.SUCESS);
                            cylindersReport.isOldJiqi = 2;
                            byte [] mimgArr = oldQiPingBean.getTup();
                            if(null != mimgArr){
                                oldQiPingBean.setTup(mimgArr);
                                BASE64Decoder decoder = new BASE64Decoder();
                                OutputStream os = new FileOutputStream(Config.UPLOADFOLDER2+"/"+sample.bsbh+"_jx.doc");
                                os.write(mimgArr, 0, mimgArr.length);
                                os.flush();
                                os.close();
                                cylindersReport.hltUrl = "/fhqp/"+sample.bsbh+"_jx.doc";
                                //保存图片到本地
                                //  boolean isok =  saveDocToLoacl2(oldQiPingBean,mimgArr,sample.bsbh+"_jx.doc",sample.bsbh);
                                //  if(isok){
                                //      cylindersReport.hltUrl = "/up/fhqp/"+sample.bsbh+"_jx.doc";
                                //   }else{
                                //       cylindersReport.hltUrl ="";
                                //   }
                            }else{
                                cylindersReport.hltUrl ="";
                            }
                            //设施报告的测试时间
                            cylindersReport.bgCsrq= oldQiPingBean.getTestTime();
                            report.cylinders = cylindersReport;
                            reportDao.save(report);
                        }
                    }
                }
            }else {
                //查询样品信息的最警的样品
                resultMsg.setCode(ResultMsg.ERROR);
            }
//            byte[] tuian = oldQiPingBean.getTup();
//            if (null != tuian && tuian.length > 0) {
//                //把图片保存起来看看
//                //转换成图片
//                BASE64Decoder decoder = new BASE64Decoder();
//                OutputStream os = new FileOutputStream("D:\\daqingdata\\bobobobobob.png");
//                os.write(tuian, 0, tuian.length);
//                os.flush();
//                os.close();
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        //}else{
        //    resultMsg.setCode(ResultMsg.FAIL);
        //}
        return resultMsg;
    }






    /**
     * 新增面罩的报告
     *
     * @param request
     * @param data
     * @return
     */
    public ResultMsg uploadBottleData(HttpServletRequest request, String data) {
        ResultMsg resultMsg = new ResultMsg();

        try {
            OtherInput mOtherInput = otherInputDao.getOtherInput();

            //如果数据是空的就不做处理
            OldMianZhao oldMianZhao = JSON.parseObject(data, OldMianZhao.class);
            if (null == oldMianZhao) {
                resultMsg.setCode(ResultMsg.ERROR);
                return resultMsg;
            }



            //------------------------------生成压力表的报告start ----------------------------------

            //查询样品信息的最警的样品
            resultMsg.setCode(ResultMsg.SUCESS);
            //根据设备编号查询样品信息
            Sample sample = mSampleDao.getPcSampleBySbbh(oldMianZhao.getCpbh());


            if (null != sample) {
                //如果当前的 样品没有分配 检验员 就不生成报告
                if(null ==sample.respirator.jcrId || "".equals(sample.respirator.jcrId)){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }
                //如果没有整机气密性和 报警声强就不生成 报告
                if("".equals(sample.respirator.zjqmx) || "".equals(sample.respirator.bjsq)){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }

                if(sample.respirator.sfjy ==-1){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }

                //先 查询这条数据有没有生成 呼吸器的报告
                Report reportOldHxq = reportDao.getReportBybsbhAdType(sample.bsbh, 1);
                if (null != reportOldHxq  && reportOldHxq.sbbh.equals(oldMianZhao.getCpbh())) {
                    //获取测试日期 2020/1/3 15:03:02

                    //获取测试日期 2020/1/3 15:03:02
                    String xxcsrr = oldMianZhao.getCsrq();
                    String bbcsrq = xxcsrr.replaceAll("\\.000000","");
                    String cccsrq = xxcsrr.replaceAll("-","/");
                    long bgCsrq22 = TimeUtil.formatDate4(cccsrq);
                    //如果报告的时间大于已经存在的报告的时间
                    if (bgCsrq22 > reportOldHxq.respirator.bgCsrq) {

                        //------------------------------生成面罩的报告start ----------------------------------
                        String  bbsdbs = oldMianZhao.getCpbh();
                        reportOldHxq.bh = sample.bh + "_mz";
                        //标识编号
                        reportOldHxq.bsbh = sample.bsbh;

                        //任务单编号
                        reportOldHxq.rwdbh = sample.rwdbh;
                        //设备编号
                        reportOldHxq.sbbh = oldMianZhao.getCpbh();
                        //样品类型
                        reportOldHxq.type = reportOldHxq.BG_TYPE_HXQ;
                        reportOldHxq.spType = sample.spType;
                        //设置短信的发送状态
                        reportOldHxq.isSendSMS = 0;
                        reportOldHxq.pxzd = sample.pxzd;
                        //接收日期时间戳
                        reportOldHxq.jsrqLong = sample.jsrqLong;

                        //面罩泄漏测试 字符串 (-206Pa 合格)
                        String mzxlceStr = oldMianZhao.getMzxlcs().trim();
                        //开启静压测试 字符串(0Pa / 279 Pa  合格)
                        String kqjyceStr = oldMianZhao.getKqjycs().trim();
                        //报警器测试（红蓝图对应的就是 报警压力测试） str (合 格 5.45MPa)
                        String bjylceStr = oldMianZhao.getBjqcs().trim();

                        //如果 面罩压力测试(50升/每分) 如：（合格）
                        String mzylcs50Str = oldMianZhao.getMzylcs50().trim();
                        //面罩压力测试(100升/每分) 如：（合格）
                        String mzylcs100Str = oldMianZhao.getMzylcs100().trim();

                        //整机气密测试 (两台的格式不一样 一台为：【1.17 MPa  合格】  另一台为【合格】)  对应正式报告的 （0~5）Pa并小于呼气阀开启压力
                        String zjqmxcsStr = oldMianZhao.getZjqmxcs().trim();

                        if("/".equals(sample.respirator.bjsq)){
                            reportOldHxq.reportStatue = 2; //不合格
                        }else{
                            //报警声强
                            double mbjsq = Double.parseDouble(sample.respirator.bjsq);
                            //
                            if ("".equals(mzxlceStr) || "".equals(kqjyceStr) || "".equals(bjylceStr) || "".equals(mzylcs50Str)
                                    || "".equals(mzylcs100Str) || "".equals(zjqmxcsStr) || mbjsq < 90) {
                                reportOldHxq.reportStatue = 2; //不合格
                            } else {
                                //如果一下任意一个包含了 不合格  整个报告算不合格
                                if (StringUtils.isBaohan(mzxlceStr, "不合格") ||
                                        StringUtils.isBaohan(kqjyceStr, "不合格") ||
                                        StringUtils.isBaohan(bjylceStr, "不合格") ||
                                        StringUtils.isBaohan(zjqmxcsStr, "不合格")) {
                                    reportOldHxq.reportStatue = 2; //不合格
                                } else {
                                    // 并且 整机气密性测试
                                    if ("合格".equals(mzylcs50Str) &&
                                            "合格".equals(mzylcs100Str) &&
                                            StringUtils.isBaohan(zjqmxcsStr, "合格") && mbjsq >= 90
                                    ) {
                                        reportOldHxq.reportStatue = 1; //合格
                                    } else {
                                        reportOldHxq.reportStatue = 2; //不合格

                                    }
                                }
                            }
                        }

                        //报告的进展  待核验
                        reportOldHxq.reportProgress = 1;

                        //子类状态先设置为0
                        reportOldHxq.failedStart = 0;
                        reportOldHxq.bsbhHrader = sample.bsbhHrader;
                        reportOldHxq.erweima = sample.erweima;
                        reportOldHxq.wtfId = sample.respirator.wtfId;
                        reportOldHxq.wtf = sample.respirator.wtf;

                        reportOldHxq.wtfIdChi = sample.wtfIdChi;
                        reportOldHxq.wtfChi = sample.wtfChi;

                        reportOldHxq.sjr = sample.sjr;
                        reportOldHxq.zzcsId = sample.zzcsId;
                        reportOldHxq.zzcs = sample.zzcs;


                        reportOldHxq.zfzddhy = 0;
                        reportOldHxq.jyyId = sample.respirator.jcrId;

                        RespiratorReport respiratorReport = new RespiratorReport();
                        respiratorReport.bh = sample.bh;
                        respiratorReport.wtfId = sample.respirator.wtfId;
                        respiratorReport.wtf = sample.respirator.wtf;
                        respiratorReport.sjrId = sample.respirator.sjrId;
                        respiratorReport.sjr = sample.respirator.sjr;
                        respiratorReport.ypmc = "正压式空气呼吸器";
                        respiratorReport.zzcsId = sample.respirator.zzcsId;
                        respiratorReport.zzcs = sample.respirator.zzcs;
                        respiratorReport.xhgg = sample.respirator.xhgg;
                        respiratorReport.ccbh = sample.respirator.ccbh;
                        if (reportOldHxq.reportStatue == 2) {
                            respiratorReport.jyjl = "不合格";
                        }
                        //如果没有代表批量 或者为空
                        if(null ==sample.respirator.dbpl || "".equals(sample.respirator.dbpl)){
                            respiratorReport.dbpl="";
                        }else{
                            respiratorReport.dbpl=sample.respirator.dbpl;
                        }
                        respiratorReport.fzdw = "";
                        respiratorReport.pzrId = "";
                        respiratorReport.pzr = "";
                        respiratorReport.hyyId = "";
                        respiratorReport.hyy = "";

                        respiratorReport.jyyId = sample.respirator.jcrId;
                        respiratorReport.jyy = sample.respirator.jcr;


                        //计算有效期
                        // 有效日期是送检日期 的下一年的前一天
                        Date date2 = new Date(bgCsrq22);

                        reportOldHxq.jyrqNian = TimeUtil.formatTime_Year(date2.getTime());
                        reportOldHxq.jyrqYue = TimeUtil.formatTime_Month(date2.getTime());
                        respiratorReport.jyrq = TimeUtil.formatTime_tow(date2.getTime());
                        respiratorReport.sjrq = sample.respirator.sjri;
                        long year2 = TimeUtil.getDateBeforeYear(date2, 1);
                        respiratorReport.yxrq = TimeUtil.formatTime_tow(year2);
                        //下次检验日期
                        reportOldHxq.xcjyrq = year2;
                        reportOldHxq.setAddTime(TimeUtil.currentTimeMillis());
                        //设置匹配气瓶的信息
                        respiratorReport.qpbsh = sample.respirator.qpbsh;
                        respiratorReport.nr_ypmc = "正压式空气呼吸器";
                        respiratorReport.nr_syrId = "";
                        respiratorReport.nr_syr = sample.respirator.sjr;
                        respiratorReport.nr_ypsl = 1;
                        respiratorReport.nr_ypztms = "完好";
                        respiratorReport.nr_sb = sample.respirator.sbstr;
//                        if(sample.respirator.sfxp ==1){
//                            respiratorReport.nr_ypdj = "新品";
//                        }else{
//                            respiratorReport.nr_ypdj = "旧品";
//                        }

                        if(sample.respirator.xjpType ==0 ||sample.respirator.xjpType ==1){
                            respiratorReport.nr_ypdj = "旧品";
                        }else{
                            respiratorReport.nr_ypdj = "新品";
                        }
                        //如果是抽检
                        if(sample.spType ==1){
                            respiratorReport.nr_jylx = "委托检验";
                        }else{
                            respiratorReport.nr_jylx = "质量抽检";
                        }

                        respiratorReport.nr_scrq = sample.respirator.scrq;
                        respiratorReport.nr_dyrq = sample.respirator.sjri;
                        respiratorReport.nr_ybhph = sample.sbbh;

                        String qunm = sample.bsbh;
                        String[] qnmmm = qunm.split("DQFJ");
                        respiratorReport.nr_ypjsbh = qnmmm[1];

                        respiratorReport.nr_jyxm = "5项";
                        respiratorReport.nr_jyyj = "AQ/T6110-2012《工业空气呼吸器安全使用维护管理规范》";
                        respiratorReport.nr_jyjl = "依据标准AQ/T6110-2012《工业空气呼吸器安全使用维护管理规范》检查，该样品索检项目符合要求。";
                        respiratorReport.nr_jfrq = "";
                        respiratorReport.nr_jybgzyz = "";
                        respiratorReport.nr_bz = "";

                        respiratorReport.nr_wg_jszb = "符合AQ/T6110-2012表 定期技术检测外观检查表要求";
                        respiratorReport.nr_wg_jyjg = "";
                        respiratorReport.nr_wg_dxpd = "";

                        respiratorReport.nr_mz_jszb = "面罩泄漏测试小于-25Pa";


                        //如果为空  就用基础数据中的整机气密性做填写  面罩泄露测试小于-25Pa
                        if ("".equals(mzxlceStr) || StringUtils.isBaohan(mzxlceStr, "不合格")) {
                            if("".equals(mzxlceStr)){
                                respiratorReport.nr_mz_dxpd = "/";
                                respiratorReport.nr_mz_jyjg = "/";
                            }else{
                                respiratorReport.nr_mz_dxpd = "不合格";
                                String zhengji11 = StringUtils.replaceBhg(mzxlceStr);
                                if ("".equals(zhengji11)) {
                                    respiratorReport.nr_mz_jyjg = "";
                                } else {
                                    respiratorReport.nr_mz_jyjg = zhengji11.trim().replace(" ","");
                                }
                            }
                        } else if (StringUtils.isBaohan(mzxlceStr, "合格")) {
                            respiratorReport.nr_mz_dxpd = "合格";
                            String zhengji11 = StringUtils.replaceHg(mzxlceStr);
                            if ("".equals(zhengji11)) {
                                respiratorReport.nr_mz_jyjg = "";
                            } else {
                                respiratorReport.nr_mz_jyjg = zhengji11.trim().replace(" ","");
                            }
                        }else{
                            respiratorReport.nr_mz_dxpd = "不合格";
                            respiratorReport.nr_mz_jyjg = "";
                        }


                        respiratorReport.nr_ylb_jszb = "压力表1min内下降不大于2MPa";
                        if ("".equals(zjqmxcsStr) || StringUtils.isBaohan(zjqmxcsStr, "不合格")) {

                            if("".equals(zjqmxcsStr)){
                                respiratorReport.nr_ylb_dxpd="/";
                                respiratorReport.nr_ylb_jyjg ="/";
                            }else{
                                respiratorReport.nr_ylb_dxpd = "不合格";
                                String zhengji11 = StringUtils.replaceBhg(zjqmxcsStr);
                                if ("".equals(zhengji11)) {
                                    respiratorReport.nr_ylb_jyjg = sample.respirator.zjqmx;
                                } else {
                                    respiratorReport.nr_ylb_jyjg = zhengji11.trim().replace(" ","");
                                }
                            }


                        } else if (StringUtils.isBaohan(zjqmxcsStr, "合格")) {
                            respiratorReport.nr_ylb_dxpd = "合格";
                            String zhengji11 = StringUtils.replaceHg(zjqmxcsStr);
                            if ("".equals(zhengji11)) {
                                respiratorReport.nr_ylb_jyjg = sample.respirator.zjqmx;
                            } else {
                                respiratorReport.nr_ylb_jyjg = zhengji11.trim().replace(" ","");
                            }
                        }else{
                            respiratorReport.nr_mz_dxpd = "不合格";
                            respiratorReport.nr_ylb_jyjg ="";
                        }

                        if("/".equals(respiratorReport.nr_ylb_jyjg)){
                            respiratorReport.nr_ylb_jyjg="";
                        }




                        respiratorReport.nr_jtyl_jszb = "（0~500）Pa并小于呼吸阀开启压力";
                        //(0Pa / 279 Pa  合格)
                        if ("".equals(kqjyceStr) || StringUtils.isBaohan(kqjyceStr, "不合格")) {

                            if("".equals(kqjyceStr)){
                                respiratorReport.nr_jtyl_dxpd = "/";
                                respiratorReport.nr_jtyl_jyjg = "/";
                            }else{
                                respiratorReport.nr_jtyl_dxpd = "不合格";
                                String jtyl11 =StringUtils.replaceBhg(kqjyceStr);

                                String[] jty22 = jtyl11.split("/");
                                if (jty22.length >= 2) {
                                    respiratorReport.nr_jtyl_jyjg = jty22[1].trim().replace(" ","");
                                }else{
                                    respiratorReport.nr_jtyl_jyjg= jty22[0].trim().replace(" ","");
                                }
                            }

                        } else if (StringUtils.isBaohan(kqjyceStr, "合格")) {
                            respiratorReport.nr_jtyl_dxpd = "合格";
                            String jtyl11 =StringUtils.replaceHg(kqjyceStr);
                            String[] jty22 = jtyl11.split("/");
                            if (jty22.length >= 2) {
                                respiratorReport.nr_jtyl_jyjg = jty22[1].trim().replace(" ","");
                            }else{
                                respiratorReport.nr_jtyl_jyjg =jty22[0].trim().replace(" ","");
                            }
                        }else{
                            respiratorReport.nr_jtyl_dxpd = "不合格";
                            respiratorReport.nr_jtyl_jyjg ="";
                        }


                        //报警压力
                        respiratorReport.nr_bjyl_jszb = "（5.5±0.5）MPa";
                        if ("".equals(bjylceStr) || StringUtils.isBaohan(bjylceStr, "不合格")) {
                            if("".equals(bjylceStr)){
                                respiratorReport.nr_bjyl_dxpd = "/";
                                respiratorReport.nr_bjyl_jyjg ="/";
                            }else{
                                respiratorReport.nr_bjyl_dxpd = "不合格";
                                String bjyal111 =StringUtils.replaceBhg(bjylceStr);
                                respiratorReport.nr_bjyl_jyjg = bjyal111.trim().replace(" ","");
                            }
                        } else if (StringUtils.isBaohan(bjylceStr, "合格")) {
                            respiratorReport.nr_bjyl_dxpd = "合格";
                            String bjyal111 =StringUtils.replaceHg(bjylceStr);
                            respiratorReport.nr_bjyl_jyjg = bjyal111.trim().replace(" ","");
                        }else{
                            respiratorReport.nr_bjyl_dxpd = "不合格";
                            respiratorReport.nr_bjyl_jyjg ="";
                        }


                        //报警声强
                        respiratorReport.nr_bjsq_jszb = "不小于90dB(A)";
                        if("/".equals(sample.respirator.bjsq)){
                            respiratorReport.nr_bjsq_dxpd = "/";
                        }else{
                            double mbjsq = Double.parseDouble(sample.respirator.bjsq);
                            respiratorReport.nr_bjsq_jyjg = mbjsq + "dB(A)";
                            if (mbjsq >= 90) {
                                respiratorReport.nr_bjsq_dxpd = "合格";
                            } else {
                                respiratorReport.nr_bjsq_dxpd = "不合格";
                            }
                        }

                        //100L/min
                        respiratorReport.nr_hxzl_mc1 = "气瓶额定压力至2MPa呼吸器频率40次/min呼吸流量100L/min";
                        respiratorReport.nr_hxzl_jszb1 = "吸气阻力不大于500Ma 呼气阻力不大于1000Pa";


                        respiratorReport.nr_hxzl_dxpd1 = mzylcs100Str;

                        if("".equals(mzylcs100Str)){
                            respiratorReport.nr_hxzl_jyjg1_x = "/";
                            respiratorReport.nr_hxzl_jyjg1_d = "/";
                        }else{
                            respiratorReport.nr_hxzl_jyjg1_x = "吸气阻力：" + oldMianZhao.getYzzxz100() + "Pa";
                            respiratorReport.nr_hxzl_jyjg1_d = "呼气阻力：" + oldMianZhao.getYlzdz100() + "Pa";
                        }

                        //50L/min
                        respiratorReport.nr_hxzl_mc2 = "气瓶额定压力至2MPa至1MPa呼吸器频率40次/min呼吸流量100L/min";
                        respiratorReport.nr_hxzl_jszb2 = "吸气阻力不大于500Ma 呼气阻力不大于700Pa";

                        respiratorReport.nr_hxzl_dxpd2 = mzylcs50Str;


                        if("".equals(mzylcs50Str)){
                            respiratorReport.nr_hxzl_jyjg2_x = "/";
                            respiratorReport.nr_hxzl_jyjg2_d = "/";
                        }else{
                            respiratorReport.nr_hxzl_jyjg2_x = "吸气阻力：" + oldMianZhao.getYlzxz50() + "Pa";
                            respiratorReport.nr_hxzl_jyjg2_d = "呼气阻力：" + oldMianZhao.getYlzdz50() + "Pa";
                        }


                        //获取测试日期 2020/1/3 15:03:02
                        String bgcerqStr = oldMianZhao.getCsrq();
                        //报告的测试日期
                        String  bgcerqStr2 =StringUtils.replaceXqn(bgcerqStr);
                        String bgcerqStr3 = bgcerqStr2.replace(".000000","");
                        String bgcerqStr4 = bgcerqStr3.replace("-","/");
                        respiratorReport.bgCsrq = TimeUtil.formatDate4(bgcerqStr4);


                        reportOldHxq.hltImg1 ="";
                        reportOldHxq.hltImg1="";

                        //------------------------红蓝图需要的数据start---------
                        HltHxqbean hltHxqbean = new HltHxqbean();
                        if(null != oldMianZhao.getCsrq() && !"".equals(oldMianZhao.getCsrq())){
                            hltHxqbean.hlt_csrq =  oldMianZhao.getCsrq();//测试日期
                        }
                        hltHxqbean.hlt_sydw = sample.respirator.wtf;
                        hltHxqbean.hlt_zzcs = sample.respirator.zzcs;
                        hltHxqbean.hlt_cpxh = sample.respirator.xhgg;
                        hltHxqbean.hlt_cpbh = sample.sbbh;

                        if(null != oldMianZhao.getZjqmxcs() && !"".equals(oldMianZhao.getZjqmxcs())){

                        }
                        if(null !=oldMianZhao.getZjqmxcs() && !"".equals(oldMianZhao.getZjqmxcs())){
                            hltHxqbean.hlt_zjqmx =oldMianZhao.getZjqmxcs();//整机气密性
                        }
                        if(null !=oldMianZhao.getMzxlcs() && !"".equals(oldMianZhao.getMzxlcs())){
                            hltHxqbean.hlt_mzxlcs = oldMianZhao.getMzxlcs();//面罩泄露测试
                        }
                        if(null !=oldMianZhao.getKqjycs() && !"".equals(oldMianZhao.getKqjycs())){
                            hltHxqbean.hlt_kqjycs =oldMianZhao.getKqjycs();//开启静压测试
                        }
                        if(null != oldMianZhao.getYlbcsjg() && !"".equals(oldMianZhao.getYlbcsjg())){
                            hltHxqbean.hlt_ylbjy_str =oldMianZhao.getYlbcsjg();//压力表校验
                        }

                        if(null !=oldMianZhao.getBjqcs() && !"".equals(oldMianZhao.getBjqcs())){
                            hltHxqbean.hlt_bjylcs = oldMianZhao.getBjqcs();
                        }

                        if(null !=oldMianZhao.getHxzlcs() && !"".equals(oldMianZhao.getHxzlcs())){
                            hltHxqbean.hlt_ylz_by1 = oldMianZhao.getHxzlcs();
                        }

                        if(null != oldMianZhao.getMznzdyl() && !"".equals(oldMianZhao.getMznzdyl())){
                            hltHxqbean.hlt_ylz_by2 = oldMianZhao.getMznzdyl();
                        }

                        if(null != oldMianZhao.getMznzxyl() && !"".equals(oldMianZhao.getMznzxyl())){
                            hltHxqbean.hlt_ylz_by3 = oldMianZhao.getMznzxyl();
                        }

                        if(null !=oldMianZhao.getYlbcs20() && !"".equals(oldMianZhao.getYlbcs20())){
                            hltHxqbean.hlt_ylz_sc1 = oldMianZhao.getYlbcs20();
                        }

                        if(null != oldMianZhao.getYlbcs10() && !"".equals(oldMianZhao.getYlbcs10())){
                            hltHxqbean.hlt_ylz_sc2 = oldMianZhao.getYlbcs10();
                        }

                        if(null !=oldMianZhao.getYlbcs70() && !"".equals(oldMianZhao.getYlbcs70())){
                            hltHxqbean.hlt_ylz_sc3 = oldMianZhao.getYlbcs70();
                        }

                        if(null !=oldMianZhao.getMzwg() && !"".equals(oldMianZhao.getMzwg())){
                            hltHxqbean.ms_mz = oldMianZhao.getMzwg();
                        }

                        if(null !=oldMianZhao.getBjbdwg() && !"".equals(oldMianZhao.getBjbdwg())){
                            hltHxqbean.ms_bjsd = oldMianZhao.getBjbdwg();
                        }

                        if(null !=oldMianZhao.getQpwg() && !"".equals(oldMianZhao.getQpwg())){
                            hltHxqbean.ms_qp = oldMianZhao.getQpwg();
                        }

                        if(null !=oldMianZhao.getDybjqwg() && !"".equals(oldMianZhao.getDybjqwg())){
                            hltHxqbean.ms_dyljg = oldMianZhao.getDybjqwg();
                        }

                        if(null !=oldMianZhao.getJgwg() && !"".equals(oldMianZhao.getJgwg())){
                            hltHxqbean.ms_jg = oldMianZhao.getJgwg();
                        }



                        if(null!= oldMianZhao.getYlzdz100() && !"".equals(oldMianZhao.getYlzdz100())){
                            hltHxqbean.hlt_zl100_d = oldMianZhao.getYlzdz100();
                        }
                        if(null!= oldMianZhao.getYzzxz100() && !"".equals(oldMianZhao.getYzzxz100())){
                            hltHxqbean.hlt_zl100_x = oldMianZhao.getYzzxz100();
                        }

                        if(null!= oldMianZhao.getMzylcs100() && !"".equals(oldMianZhao.getMzylcs100())){
                            hltHxqbean.hlt_zl100_jg = oldMianZhao.getMzylcs100();
                        }

                        if(null!= oldMianZhao.getYlzdz50() && !"".equals( oldMianZhao.getYlzdz50())){
                            hltHxqbean.hlt_zl50_d = oldMianZhao.getYlzdz50();
                        }

                        if(null!= oldMianZhao.getYlzxz50() && !"".equals( oldMianZhao.getYlzxz50())){
                            hltHxqbean.hlt_zl50_x = oldMianZhao.getYlzxz50();
                        }
                        if(null!= oldMianZhao.getMzylcs50() && !"".equals( oldMianZhao.getMzylcs50())){
                            hltHxqbean.hlt_zl50_jg = oldMianZhao.getMzylcs50();
                        }

                        reportOldHxq.hltImg1 ="";
                        reportOldHxq.hltImg2="";
                        respiratorReport.khxinBean = hltHxqbean;
                        //------------------------红蓝图需要的数据end---------


                        reportOldHxq.respirator = respiratorReport;
                        reportDao.save(reportOldHxq);
                        //------------------------------生成面罩的报告end ------------------------------------
                    }
                } else {
                    //------------------------------生成面罩的报告start ----------------------------------

                    if(!"".equals(oldMianZhao.getCsrq())){
                        //获取测试日期 2020/1/3 15:03:02
                        String xxcsrr = oldMianZhao.getCsrq();
                        String bbcsrq = xxcsrr.replaceAll("\\.000000","");
                        String cccsrq = xxcsrr.replaceAll("-","/");


                        long bgCsrq33 = TimeUtil.formatDate4(cccsrq);
                        //如果送检日期的时间戳 减去 实验数据上面的时间戳  两者相差超过20天  就不用生成报告
                        int chazhi = TimeUtil.getOffectDay(sample.jsrqLong,bgCsrq33);
                        int difference = Math.abs(chazhi);
                        //如果差值小于20天 就生成数据
                        if(difference< Config.SJSC_DAY){
                            String  bbsdbs = oldMianZhao.getCpbh();
                            Report report = new Report();
                            report.bh = sample.bh + "_mz";
                            //标识编号
                            report.bsbh = sample.bsbh;
                            //任务单编号
                            report.rwdbh = sample.rwdbh;
                            //设备编号
                            report.sbbh = oldMianZhao.getCpbh();
                            //样品类型
                            report.type = report.BG_TYPE_HXQ;
                            report.spType = sample.spType;
                            //设置短信的发送状态
                            report.isSendSMS = 0;
                            report.pxzd = sample.pxzd;
                            //接收日期时间戳
                            report.jsrqLong = sample.jsrqLong;

                            //面罩泄漏测试 字符串 (-206Pa 合格)
                            String mzxlceStr = oldMianZhao.getMzxlcs().trim();
                            //开启静压测试 字符串(0Pa / 279 Pa  合格)
                            String kqjyceStr = oldMianZhao.getKqjycs().trim();
                            //报警器测试（红蓝图对应的就是 报警压力测试） str (合 格 5.45MPa)
                            String bjylceStr = oldMianZhao.getBjqcs().trim();

                            //如果 面罩压力测试(50升/每分) 如：（合格）
                            String mzylcs50Str = oldMianZhao.getMzylcs50().trim();
                            //面罩压力测试(100升/每分) 如：（合格）
                            String mzylcs100Str = oldMianZhao.getMzylcs100().trim();

                            //整机气密测试 (两台的格式不一样 一台为：【1.17 MPa  合格】  另一台为【合格】)  对应正式报告的 （
                            String zjqmxcsStr = oldMianZhao.getZjqmxcs().trim();

                            if("/".equals(sample.respirator.bjsq)){
                                report.reportStatue = 2; //不合格
                            }else{
                                //报警声强
                                double mbjsq = Double.parseDouble(sample.respirator.bjsq);
                                if ("".equals(mzxlceStr) || "".equals(kqjyceStr) || "".equals(bjylceStr) || "".equals(mzylcs50Str)
                                        || "".equals(mzylcs100Str) || "".equals(zjqmxcsStr) || mbjsq < 90) {
                                    report.reportStatue = 2; //不合格
                                } else {
                                    //如果一下任意一个包含了 不合格  整个报告算不合格
                                    if (StringUtils.isBaohan(mzxlceStr, "不合格") ||
                                            StringUtils.isBaohan(kqjyceStr, "不合格") ||
                                            StringUtils.isBaohan(bjylceStr, "不合格") ||
                                            StringUtils.isBaohan(zjqmxcsStr, "不合格")) {
                                        report.reportStatue = 2; //不合格
                                    } else {
                                        // 并且 整机气密性测试
                                        if ("合格".equals(mzylcs50Str) &&
                                                "合格".equals(mzylcs100Str) &&
                                                StringUtils.isBaohan(zjqmxcsStr, "合格") && mbjsq >= 90
                                        ) {
                                            report.reportStatue = 1; //合格
                                        } else {
                                            report.reportStatue = 2; //不合格

                                        }
                                    }
                                }
                            }


                            //报告的进展  待核验
                            report.reportProgress = 1;

                            //子类状态先设置为0
                            report.failedStart = 0;
                            report.bsbhHrader = sample.bsbhHrader;
                            report.erweima = sample.erweima;
                            report.wtfId = sample.respirator.wtfId;
                            report.wtf = sample.respirator.wtf;
                            report.wtfIdChi = sample.wtfIdChi;
                            report.wtfChi = sample.wtfChi;

                            report.sjr = sample.sjr;
                            report.zzcsId = sample.zzcsId;
                            report.zzcs = sample.zzcs;
                            report.zfzddhy = 0;
                            report.jyyId = sample.respirator.jcrId;

                            RespiratorReport respiratorReport = new RespiratorReport();
                            respiratorReport.bh = sample.bh;
                            respiratorReport.wtfId = sample.respirator.wtfId;
                            respiratorReport.wtf = sample.respirator.wtf;
                            respiratorReport.sjrId = sample.respirator.sjrId;
                            respiratorReport.sjr = sample.respirator.sjr;
                            respiratorReport.ypmc = "正压式空气呼吸器";
                            respiratorReport.zzcsId = sample.respirator.zzcsId;
                            respiratorReport.zzcs = sample.respirator.zzcs;
                            respiratorReport.xhgg = sample.respirator.xhgg;
                            respiratorReport.ccbh = sample.respirator.ccbh;
                            if (report.reportStatue == 2) {
                                respiratorReport.jyjl = "不合格";
                            }
                            //如果没有代表批量 或者为空
                            if(null ==sample.respirator.dbpl || "".equals(sample.respirator.dbpl)){
                                respiratorReport.dbpl="";
                            }else{
                                respiratorReport.dbpl=sample.respirator.dbpl;
                            }
                            if(mOtherInput==null){
                                respiratorReport.jydwsqh = mOtherInput.mz_jydwsqh;
                            }else{
                                respiratorReport.jydwsqh =Config.MZ_JTDWSQH;
                            }
                            respiratorReport.fzdw = "";
                            respiratorReport.pzrId = "";
                            respiratorReport.pzr = "";
                            respiratorReport.hyyId = "";
                            respiratorReport.hyy = "";

                            respiratorReport.jyyId = sample.respirator.jcrId;
                            respiratorReport.jyy = sample.respirator.jcr;


                            //计算有效期
                            // 有效日期是送检日期 的下一年的前一天
                            Date date2 = new Date(bgCsrq33);
                            report.jyrqNian = TimeUtil.formatTime_Year(date2.getTime());
                            report.jyrqYue = TimeUtil.formatTime_Month(date2.getTime());
                            respiratorReport.jyrq = TimeUtil.formatTime_tow(date2.getTime());
                            respiratorReport.sjrq = sample.respirator.sjri;

                            long year2 = TimeUtil.getDateBeforeYear(date2, 1);
                            respiratorReport.yxrq = TimeUtil.formatTime_tow(year2);
                            //下次检验日期
                            report.xcjyrq = year2;
                            report.setAddTime(TimeUtil.currentTimeMillis());
                            //设置匹配气瓶的信息
                            respiratorReport.qpbsh = sample.respirator.qpbsh;
                            respiratorReport.nr_ypmc = "正压式空气呼吸器";
                            respiratorReport.nr_syrId = "";
                            respiratorReport.nr_syr = sample.respirator.sjr;
                            respiratorReport.nr_ypsl = 1;
                            respiratorReport.nr_ypztms = "完好";
                            respiratorReport.nr_sb = sample.respirator.sbstr;
                            respiratorReport.nr_sb = sample.respirator.sbstr;
//                            if(sample.respirator.sfxp ==1){
//                                respiratorReport.nr_ypdj = "新品";
//                            }else{
//                                respiratorReport.nr_ypdj = "旧品";
//                            }
                            if(sample.respirator.xjpType ==0 ||sample.respirator.xjpType ==1){
                                respiratorReport.nr_ypdj = "旧品";
                            }else{
                                respiratorReport.nr_ypdj = "新品";
                            }
                            //如果是抽检
                            if(sample.spType ==1){
                                respiratorReport.nr_jylx = "委托检验";
                            }else{
                                respiratorReport.nr_jylx = "质量抽检";
                            }
                            respiratorReport.nr_scrq = sample.respirator.scrq;
                            respiratorReport.nr_dyrq = sample.respirator.sjri;
                            respiratorReport.nr_ybhph = sample.sbbh;

                            String qunm = sample.bsbh;
                            String[] qnmmm = qunm.split("DQFJ");
                            respiratorReport.nr_ypjsbh = qnmmm[1];

                            respiratorReport.nr_jyxm = "5项";
                            respiratorReport.nr_jyyj = "AQ/T6110-2012《工业空气呼吸器安全使用维护管理规范》";
                            respiratorReport.nr_jyjl = "依据标准AQ/T6110-2012《工业空气呼吸器安全使用维护管理规范》检查，该样品索检项目符合要求。";
                            respiratorReport.nr_jfrq = "";
                            respiratorReport.nr_jybgzyz = "";
                            respiratorReport.nr_bz = "";

                            respiratorReport.nr_wg_jszb = "符合AQ/T6110-2012表 定期技术检测外观检查表要求";
                            respiratorReport.nr_wg_jyjg = "";
                            respiratorReport.nr_wg_dxpd = "";
                            respiratorReport.nr_mz_jszb = "面罩泄漏测试小于-25Pa";

                            //如果为空  就用基础数据中的整机气密性做填写  面罩泄露测试小于-25Pa
                            if ("".equals(mzxlceStr) || StringUtils.isBaohan(mzxlceStr, "不合格")) {
                                if("".equals(mzxlceStr)){
                                    respiratorReport.nr_mz_dxpd = "/";
                                    respiratorReport.nr_mz_jyjg = "/";
                                }else{
                                    respiratorReport.nr_mz_dxpd = "不合格";
                                    String zhengji11 = StringUtils.replaceBhg(mzxlceStr);
                                    if ("".equals(zhengji11)) {
                                        respiratorReport.nr_mz_jyjg = "";
                                    } else {
                                        respiratorReport.nr_mz_jyjg = zhengji11.trim().replace(" ","");
                                    }
                                }
                            } else if (StringUtils.isBaohan(mzxlceStr, "合格")) {
                                respiratorReport.nr_mz_dxpd = "合格";
                                String zhengji11 = StringUtils.replaceHg(mzxlceStr);
                                if ("".equals(zhengji11)) {
                                    respiratorReport.nr_mz_jyjg = "";
                                } else {
                                    respiratorReport.nr_mz_jyjg = zhengji11.trim().replace(" ","");
                                }
                            }else{
                                respiratorReport.nr_mz_dxpd = "不合格";
                                respiratorReport.nr_mz_jyjg = "";
                            }





                            respiratorReport.nr_ylb_jszb = "压力表1min内下降不大于2MPa";
                            if ("".equals(zjqmxcsStr) || StringUtils.isBaohan(zjqmxcsStr, "不合格")) {

                                if("".equals(zjqmxcsStr)){
                                    respiratorReport.nr_ylb_dxpd="/";
                                    respiratorReport.nr_ylb_jyjg ="/";
                                }else{
                                    respiratorReport.nr_ylb_dxpd = "不合格";
                                    String zhengji11 = StringUtils.replaceBhg(zjqmxcsStr);
                                    if ("".equals(zhengji11)) {
                                        respiratorReport.nr_ylb_jyjg = sample.respirator.zjqmx;
                                    } else {
                                        respiratorReport.nr_ylb_jyjg = zhengji11.trim().replace(" ","");
                                    }
                                }


                            } else if (StringUtils.isBaohan(zjqmxcsStr, "合格")) {
                                respiratorReport.nr_ylb_dxpd = "合格";
                                String zhengji11 = StringUtils.replaceHg(zjqmxcsStr);
                                if ("".equals(zhengji11)) {
                                    respiratorReport.nr_ylb_jyjg = sample.respirator.zjqmx;
                                } else {
                                    respiratorReport.nr_ylb_jyjg = zhengji11.trim().replace(" ","");
                                }
                            }else{
                                respiratorReport.nr_mz_dxpd = "不合格";
                                respiratorReport.nr_ylb_jyjg ="";
                            }

                            if("/".equals(respiratorReport.nr_ylb_jyjg)){
                                respiratorReport.nr_ylb_jyjg="";
                            }




                            respiratorReport.nr_jtyl_jszb = "（0~500）Pa并小于呼吸阀开启压力";
                            //(0Pa / 279 Pa  合格)
                            if ("".equals(kqjyceStr) || StringUtils.isBaohan(kqjyceStr, "不合格")) {

                                if("".equals(kqjyceStr)){
                                    respiratorReport.nr_jtyl_dxpd = "/";
                                    respiratorReport.nr_jtyl_jyjg = "/";
                                }else{
                                    respiratorReport.nr_jtyl_dxpd = "不合格";
                                    String jtyl11 =StringUtils.replaceBhg(kqjyceStr);

                                    String[] jty22 = jtyl11.split("/");
                                    if (jty22.length >= 2) {
                                        respiratorReport.nr_jtyl_jyjg = jty22[1].trim().replace(" ","");
                                    }else{
                                        respiratorReport.nr_jtyl_jyjg=jty22[0].trim().replace(" ","");
                                    }
                                }

                            } else if (StringUtils.isBaohan(kqjyceStr, "合格")) {
                                respiratorReport.nr_jtyl_dxpd = "合格";
                                String jtyl11 =StringUtils.replaceHg(kqjyceStr);
                                String[] jty22 = jtyl11.split("/");
                                if (jty22.length >= 2) {
                                    respiratorReport.nr_jtyl_jyjg = jty22[1].trim().replace(" ","");
                                }else{
                                    respiratorReport.nr_jtyl_jyjg =jty22[0].trim().replace(" ","");
                                }
                            }else{
                                respiratorReport.nr_jtyl_dxpd = "不合格";
                                respiratorReport.nr_jtyl_jyjg ="";
                            }




                            //报警压力
                            respiratorReport.nr_bjyl_jszb = "（5.5±0.5）MPa";
                            if ("".equals(bjylceStr) || StringUtils.isBaohan(bjylceStr, "不合格")) {
                                if("".equals(bjylceStr)){
                                    respiratorReport.nr_bjyl_dxpd = "/";
                                    respiratorReport.nr_bjyl_jyjg ="/";
                                }else{
                                    respiratorReport.nr_bjyl_dxpd = "不合格";
                                    String bjyal111 =StringUtils.replaceBhg(bjylceStr);
                                    respiratorReport.nr_bjyl_jyjg = bjyal111.trim().replace(" ","");
                                }
                            } else if (StringUtils.isBaohan(bjylceStr, "合格")) {
                                respiratorReport.nr_bjyl_dxpd = "合格";
                                String bjyal111 =StringUtils.replaceHg(bjylceStr);
                                respiratorReport.nr_bjyl_jyjg = bjyal111.trim().replace(" ","");
                            }else{
                                respiratorReport.nr_bjyl_dxpd = "不合格";
                                respiratorReport.nr_bjyl_jyjg ="";
                            }


                            //报警声强
                            respiratorReport.nr_bjsq_jszb = "不小于90dB(A)";
                            if("/".equals(sample.respirator.bjsq)){
                                respiratorReport.nr_bjsq_dxpd = "/";
                            }else{
                                double mbjsq = Double.parseDouble(sample.respirator.bjsq);
                                respiratorReport.nr_bjsq_jyjg = mbjsq + "dB(A)";
                                if (mbjsq >= 90) {
                                    respiratorReport.nr_bjsq_dxpd = "合格";
                                } else {
                                    respiratorReport.nr_bjsq_dxpd = "不合格";
                                }
                            }

                            //100L/min
                            respiratorReport.nr_hxzl_mc1 = "气瓶额定压力至2MPa呼吸器频率40次/min呼吸流量100L/min";
                            respiratorReport.nr_hxzl_jszb1 = "吸气阻力不大于500Ma 呼气阻力不大于1000Pa";


                            respiratorReport.nr_hxzl_dxpd1 = mzylcs100Str;

                            if("".equals(mzylcs100Str)){
                                respiratorReport.nr_hxzl_jyjg1_x = "/";
                                respiratorReport.nr_hxzl_jyjg1_d = "/";
                            }else{
                                respiratorReport.nr_hxzl_jyjg1_x = "吸气阻力：" + oldMianZhao.getYzzxz100() + "Pa";
                                respiratorReport.nr_hxzl_jyjg1_d = "呼气阻力：" + oldMianZhao.getYlzdz100() + "Pa";
                            }



                            //50L/min
                            respiratorReport.nr_hxzl_mc2 = "气瓶额定压力至2MPa至1MPa呼吸器频率40次/min呼吸流量100L/min";
                            respiratorReport.nr_hxzl_jszb2 = "吸气阻力不大于500Ma 呼气阻力不大于700Pa";

                            respiratorReport.nr_hxzl_dxpd2 = mzylcs50Str;


                            if("".equals(mzylcs50Str)){
                                respiratorReport.nr_hxzl_jyjg2_x = "/";
                                respiratorReport.nr_hxzl_jyjg2_d = "/";
                            }else{
                                respiratorReport.nr_hxzl_jyjg2_x = "吸气阻力：" + oldMianZhao.getYlzxz50() + "Pa";
                                respiratorReport.nr_hxzl_jyjg2_d = "呼气阻力：" + oldMianZhao.getYlzdz50() + "Pa";
                            }





                            //获取测试日期 2020/1/3 15:03:02
                            String bgcerqStr = oldMianZhao.getCsrq();
                            //报告的测试日期
                            String  bgcerqStr2 =StringUtils.replaceXqn(bgcerqStr);
                            String bgcerqStr3 = bgcerqStr2.replace(".000000","");
                            String bgcerqStr4 = bgcerqStr3.replace("-","/");
                            respiratorReport.bgCsrq = TimeUtil.formatDate4(bgcerqStr4);


                            report.hltImg1 ="";
                            report.hltImg1="";

                            //------------------------红蓝图需要的数据start---------
                            HltHxqbean hltHxqbean = new HltHxqbean();
                            if(null != oldMianZhao.getCsrq() && !"".equals(oldMianZhao.getCsrq())){
                                hltHxqbean.hlt_csrq =  oldMianZhao.getCsrq();//测试日期
                            }
                            hltHxqbean.hlt_sydw = sample.respirator.wtf;
                            hltHxqbean.hlt_zzcs = sample.respirator.zzcs;
                            hltHxqbean.hlt_cpxh = sample.respirator.xhgg;
                            hltHxqbean.hlt_cpbh = sample.sbbh;


                            if(null !=oldMianZhao.getZjqmxcs() && !"".equals(oldMianZhao.getZjqmxcs())){
                                hltHxqbean.hlt_zjqmx =oldMianZhao.getZjqmxcs();//整机气密性
                            }
                            if(null !=oldMianZhao.getMzxlcs() && !"".equals(oldMianZhao.getMzxlcs())){
                                hltHxqbean.hlt_mzxlcs = oldMianZhao.getMzxlcs();//面罩泄露测试
                            }
                            if(null !=oldMianZhao.getKqjycs() && !"".equals(oldMianZhao.getKqjycs())){
                                hltHxqbean.hlt_kqjycs =oldMianZhao.getKqjycs();//开启静压测试
                            }
                            if(null != oldMianZhao.getYlbcsjg() && !"".equals(oldMianZhao.getYlbcsjg())){
                                hltHxqbean.hlt_ylbjy_str =oldMianZhao.getYlbcsjg();//压力表校验
                            }

                            if(null !=oldMianZhao.getBjqcs() && !"".equals(oldMianZhao.getBjqcs())){
                                hltHxqbean.hlt_bjylcs = oldMianZhao.getBjqcs();
                            }

                            if(null !=oldMianZhao.getHxzlcs() && !"".equals(oldMianZhao.getHxzlcs())){
                                hltHxqbean.hlt_ylz_by1 = oldMianZhao.getHxzlcs();
                            }

                            if(null != oldMianZhao.getMznzdyl() && !"".equals(oldMianZhao.getMznzdyl())){
                                hltHxqbean.hlt_ylz_by2 = oldMianZhao.getMznzdyl();
                            }

                            if(null != oldMianZhao.getMznzxyl() && !"".equals(oldMianZhao.getMznzxyl())){
                                hltHxqbean.hlt_ylz_by3 = oldMianZhao.getMznzxyl();
                            }

                            if(null !=oldMianZhao.getYlbcs20() && !"".equals(oldMianZhao.getYlbcs20())){
                                hltHxqbean.hlt_ylz_sc1 = oldMianZhao.getYlbcs20();
                            }

                            if(null != oldMianZhao.getYlbcs10() && !"".equals(oldMianZhao.getYlbcs10())){
                                hltHxqbean.hlt_ylz_sc2 = oldMianZhao.getYlbcs10();
                            }

                            if(null !=oldMianZhao.getYlbcs70() && !"".equals(oldMianZhao.getYlbcs70())){
                                hltHxqbean.hlt_ylz_sc3 = oldMianZhao.getYlbcs70();
                            }

                            if(null !=oldMianZhao.getMzwg() && !"".equals(oldMianZhao.getMzwg())){
                                hltHxqbean.ms_mz = oldMianZhao.getMzwg();
                            }

                            if(null !=oldMianZhao.getBjbdwg() && !"".equals(oldMianZhao.getBjbdwg())){
                                hltHxqbean.ms_bjsd = oldMianZhao.getBjbdwg();
                            }

                            if(null !=oldMianZhao.getQpwg() && !"".equals(oldMianZhao.getQpwg())){
                                hltHxqbean.ms_qp = oldMianZhao.getQpwg();
                            }

                            if(null !=oldMianZhao.getDybjqwg() && !"".equals(oldMianZhao.getDybjqwg())){
                                hltHxqbean.ms_dyljg = oldMianZhao.getDybjqwg();
                            }

                            if(null !=oldMianZhao.getJgwg() && !"".equals(oldMianZhao.getJgwg())){
                                hltHxqbean.ms_jg = oldMianZhao.getJgwg();
                            }



                            if(null!= oldMianZhao.getYlzdz100() && !"".equals(oldMianZhao.getYlzdz100())){
                                hltHxqbean.hlt_zl100_d = oldMianZhao.getYlzdz100();
                            }
                            if(null!= oldMianZhao.getYzzxz100() && !"".equals(oldMianZhao.getYzzxz100())){
                                hltHxqbean.hlt_zl100_x = oldMianZhao.getYzzxz100();
                            }

                            if(null!= oldMianZhao.getMzylcs100() && !"".equals(oldMianZhao.getMzylcs100())){
                                hltHxqbean.hlt_zl100_jg = oldMianZhao.getMzylcs100();
                            }

                            if(null!= oldMianZhao.getYlzdz50() && !"".equals( oldMianZhao.getYlzdz50())){
                                hltHxqbean.hlt_zl50_d = oldMianZhao.getYlzdz50();
                            }

                            if(null!= oldMianZhao.getYlzxz50() && !"".equals( oldMianZhao.getYlzxz50())){
                                hltHxqbean.hlt_zl50_x = oldMianZhao.getYlzxz50();
                            }
                            if(null!= oldMianZhao.getMzylcs50() && !"".equals( oldMianZhao.getMzylcs50())){
                                hltHxqbean.hlt_zl50_jg = oldMianZhao.getMzylcs50();
                            }

                            report.hltImg1 ="";
                            report.hltImg2="";
                            respiratorReport.khxinBean = hltHxqbean;
                            //------------------------红蓝图需要的数据end---------


                            report.respirator = respiratorReport;
                            reportDao.save(report);
                        }
                    }
                    //------------------------------生成面罩的报告end ------------------------------------
                }


                //先 查询这条数据有没有生成 呼吸器的报告
                Report reportOldYlb = reportDao.getReportBybsbhAdType(sample.bsbh, 3);
                //如果压力表的 报告已经存在了
                if (null != reportOldYlb  &&  reportOldYlb.sbbh.equals(oldMianZhao.getCpbh())) {
                    //获取测试日期 2020/1/3 15:03:02
                    String xxcsrr = oldMianZhao.getCsrq();
                    String bbcsrq = xxcsrr.replaceAll("\\.000000","");
                    String cccsrq = xxcsrr.replaceAll("-","/");
                    //获取测试日期 2020/1/3 15:03:02
                    long bgCsrq22 = TimeUtil.formatDate4(cccsrq);
                    if (bgCsrq22 > reportOldYlb.pressure.bgCsrq) {
                        //------------------------------生成压力表的报告start ------------------------------------
                        reportOldYlb.bh = sample.bh + "_ylb";
                        //标识编号
                        reportOldYlb.bsbh = sample.bsbh;
                        //设备编号
                        reportOldYlb.sbbh = oldMianZhao.getCpbh();

                        //任务单编号
                        reportOldYlb.rwdbh = sample.rwdbh;
                        //样品类型
                        reportOldYlb.type = reportOldYlb.BG_TYPE_YLB;
                        reportOldYlb.spType = sample.spType;
                        reportOldYlb.setAddTime(TimeUtil.currentTimeMillis());
                        reportOldYlb.pxzd = sample.pxzd;
                        //接收日期时间戳
                        reportOldYlb.jsrqLong = sample.jsrqLong;

                        //压力表表报告结果
                        String ylbcsjgStr = oldMianZhao.getYlbcsjg().trim();
                        //压力表测试(20MPa)
                        String ylbcs20Str = oldMianZhao.getYlbcs20().trim();
                        //压力表测试(10MPa)
                        String ylbcs10Str = oldMianZhao.getYlbcs10().trim();
                        //压力表测试(7MPa)
                        String ylbcs70Str = oldMianZhao.getYlbcs70().trim();

                        //呼吸阻力测试
                        String hxzlcsStr = oldMianZhao.getHxzlcs().trim();
                        //面罩内最大压力
                        String mznzdylStr = oldMianZhao.getMznzdyl().trim();
                        //面罩内最小压力
                        String mznzxylStr = oldMianZhao.getMznzxyl().trim();

                        PressureReport pressureReport = new PressureReport();

                        if ("合格".equals(ylbcsjgStr) && !"".equals(ylbcs20Str) && !"".equals(ylbcs10Str) && !"".equals(ylbcs70Str) &&
                                !"".equals(hxzlcsStr) && !"".equals(mznzdylStr) && !"".equals(mznzxylStr)) {
                            reportOldYlb.reportStatue = 1; //合格
                            pressureReport.jl = "本次压力表校验合格。";
                            //子类状态先设置为0
                            reportOldYlb.failedStart = 0;

                        } else {
                            reportOldYlb.reportStatue = 2; //不合格
                            if ("".equals(ylbcs20Str) && "".equals(ylbcs10Str) && "".equals(ylbcs70Str) && "".equals(hxzlcsStr) && "".equals(mznzdylStr) && "".equals(mznzxylStr)) {
                                pressureReport.jl = "本次压力表未进行校验。";
                                //子类状态先设置为0
                                reportOldYlb.failedStart = 1;
                            } else {
                                pressureReport.jl = "本次压力表校验不合格。";
                                //子类状态先设置为0
                                reportOldYlb.failedStart = 0;
                            }
                        }
                        //报告的进展  待核验
                        reportOldYlb.reportProgress = 1;

                        reportOldYlb.bsbhHrader = sample.bsbhHrader;
                        reportOldYlb.erweima = sample.erweima;
                        reportOldYlb.wtfId = sample.respirator.wtfId;
                        reportOldYlb.wtf = sample.respirator.wtf;

                        reportOldYlb.wtfIdChi = sample.wtfIdChi;
                        reportOldYlb.wtfChi = sample.wtfChi;

                        reportOldYlb.sjr = sample.sjr;
                        reportOldYlb.zzcsId = sample.zzcsId;
                        reportOldYlb.zzcs = sample.zzcs;


                        reportOldYlb.jyrqNian =TimeUtil.formatTime_Year(bgCsrq22);
                        reportOldYlb.jyrqYue = TimeUtil.formatTime_Month(bgCsrq22);
                        reportOldYlb.zfzddhy = 0;
                        reportOldYlb.jyyId = sample.respirator.jcrId;

                        if ("".equals(hxzlcsStr)) {
                            pressureReport.scz1 = "/";
                        } else {
                            pressureReport.scz1 = hxzlcsStr;
                        }
                        if ("".equals(mznzdylStr)) {
                            pressureReport.scz2 = "/";
                        } else {
                            pressureReport.scz2 = mznzdylStr;
                        }
                        if ("".equals(mznzxylStr)) {
                            pressureReport.scz3 = "/";
                        } else {
                            pressureReport.scz3 = mznzxylStr;
                        }


                        if ("".equals(ylbcs20Str)) {
                            pressureReport.byz1 = "/";
                        } else {
                            pressureReport.byz1 = ylbcs20Str;
                        }

                        if ("".equals(ylbcs10Str)) {
                            pressureReport.byz2 = "/";
                        } else {
                            pressureReport.byz2 = ylbcs10Str;
                        }

                        if ("".equals(ylbcs70Str)) {
                            pressureReport.byz3 = "/";
                        } else {
                            pressureReport.byz3 = ylbcs70Str;
                        }










                        //------------------------红蓝图需要的数据start---------
                        HltHxqbean hltHxqbean = new HltHxqbean();
                        if(null != oldMianZhao.getCsrq() && !"".equals(oldMianZhao.getCsrq())){
                            hltHxqbean.hlt_csrq =  oldMianZhao.getCsrq();//测试日期
                        }
                        hltHxqbean.hlt_sydw = sample.respirator.wtf;
                        hltHxqbean.hlt_zzcs = sample.respirator.zzcs;
                        hltHxqbean.hlt_cpxh = sample.respirator.xhgg;
                        hltHxqbean.hlt_cpbh = sample.sbbh;

                        if(null != oldMianZhao.getZjqmxcs() && !"".equals(oldMianZhao.getZjqmxcs())){

                        }
                        if(null !=oldMianZhao.getZjqmxcs() && !"".equals(oldMianZhao.getZjqmxcs())){
                            hltHxqbean.hlt_zjqmx =oldMianZhao.getZjqmxcs();//整机气密性
                        }
                        if(null !=oldMianZhao.getMzxlcs() && !"".equals(oldMianZhao.getMzxlcs())){
                            hltHxqbean.hlt_mzxlcs = oldMianZhao.getMzxlcs();//面罩泄露测试
                        }
                        if(null !=oldMianZhao.getKqjycs() && !"".equals(oldMianZhao.getKqjycs())){
                            hltHxqbean.hlt_kqjycs =oldMianZhao.getKqjycs();//开启静压测试
                        }
                        if(null != oldMianZhao.getYlbcsjg() && !"".equals(oldMianZhao.getYlbcsjg())){
                            hltHxqbean.hlt_ylbjy_str =oldMianZhao.getYlbcsjg();//压力表校验
                        }

                        if(null !=oldMianZhao.getBjqcs() && !"".equals(oldMianZhao.getBjqcs())){
                            hltHxqbean.hlt_bjylcs = oldMianZhao.getBjqcs();
                        }

                        if(null !=oldMianZhao.getHxzlcs() && !"".equals(oldMianZhao.getHxzlcs())){
                            hltHxqbean.hlt_ylz_by1 = oldMianZhao.getHxzlcs();
                        }

                        if(null != oldMianZhao.getMznzdyl() && !"".equals(oldMianZhao.getMznzdyl())){
                            hltHxqbean.hlt_ylz_by2 = oldMianZhao.getMznzdyl();
                        }

                        if(null != oldMianZhao.getMznzxyl() && !"".equals(oldMianZhao.getMznzxyl())){
                            hltHxqbean.hlt_ylz_by3 = oldMianZhao.getMznzxyl();
                        }

                        if(null !=oldMianZhao.getYlbcs20() && !"".equals(oldMianZhao.getYlbcs20())){
                            hltHxqbean.hlt_ylz_sc1 = oldMianZhao.getYlbcs20();
                        }

                        if(null != oldMianZhao.getYlbcs10() && !"".equals(oldMianZhao.getYlbcs10())){
                            hltHxqbean.hlt_ylz_sc2 = oldMianZhao.getYlbcs10();
                        }

                        if(null !=oldMianZhao.getYlbcs70() && !"".equals(oldMianZhao.getYlbcs70())){
                            hltHxqbean.hlt_ylz_sc3 = oldMianZhao.getYlbcs70();
                        }

                        if(null !=oldMianZhao.getMzwg() && !"".equals(oldMianZhao.getMzwg())){
                            hltHxqbean.ms_mz = oldMianZhao.getMzwg();
                        }

                        if(null !=oldMianZhao.getBjbdwg() && !"".equals(oldMianZhao.getBjbdwg())){
                            hltHxqbean.ms_bjsd = oldMianZhao.getBjbdwg();
                        }

                        if(null !=oldMianZhao.getQpwg() && !"".equals(oldMianZhao.getQpwg())){
                            hltHxqbean.ms_qp = oldMianZhao.getQpwg();
                        }

                        if(null !=oldMianZhao.getDybjqwg() && !"".equals(oldMianZhao.getDybjqwg())){
                            hltHxqbean.ms_dyljg = oldMianZhao.getDybjqwg();
                        }

                        if(null !=oldMianZhao.getJgwg() && !"".equals(oldMianZhao.getJgwg())){
                            hltHxqbean.ms_jg = oldMianZhao.getJgwg();
                        }



                        if(null!= oldMianZhao.getYlzdz100() && !"".equals(oldMianZhao.getYlzdz100())){
                            hltHxqbean.hlt_zl100_d = oldMianZhao.getYlzdz100();
                        }
                        if(null!= oldMianZhao.getYzzxz100() && !"".equals(oldMianZhao.getYzzxz100())){
                            hltHxqbean.hlt_zl100_x = oldMianZhao.getYzzxz100();
                        }

                        if(null!= oldMianZhao.getMzylcs100() && !"".equals(oldMianZhao.getMzylcs100())){
                            hltHxqbean.hlt_zl100_jg = oldMianZhao.getMzylcs100();
                        }

                        if(null!= oldMianZhao.getYlzdz50() && !"".equals( oldMianZhao.getYlzdz50())){
                            hltHxqbean.hlt_zl50_d = oldMianZhao.getYlzdz50();
                        }

                        if(null!= oldMianZhao.getYlzxz50() && !"".equals( oldMianZhao.getYlzxz50())){
                            hltHxqbean.hlt_zl50_x = oldMianZhao.getYlzxz50();
                        }
                        if(null!= oldMianZhao.getMzylcs50() && !"".equals( oldMianZhao.getMzylcs50())){
                            hltHxqbean.hlt_zl50_jg = oldMianZhao.getMzylcs50();
                        }

                        reportOldYlb.hltImg1 ="";
                        reportOldYlb.hltImg2="";
                        pressureReport.khxinBean = hltHxqbean;
                        //------------------------红蓝图需要的数据end---------

                        if(null!=mOtherInput){
                            //检验单位授权号
                            pressureReport.jydwsqh = mOtherInput.ylb_jydwsqh;
                        }else{
                            //检验单位授权号
                            pressureReport.jydwsqh = Config.YLB_JTDWSQH;
                        }


                        pressureReport.jyyId = sample.respirator.jcrId;
                        pressureReport.jyy = sample.respirator.jcr;
                        pressureReport.jyrq = sample.respirator.sjri;
                        //获取测试日期 2020/1/3 15:03:02
                        String bgcerqStr = oldMianZhao.getCsrq();
                        //报告的测试日期
                        String  bgcerqStr2 =StringUtils.replaceXqn(bgcerqStr);
                        String bgcerqStr3 = bgcerqStr2.replace(".000000","");
                        String bgcerqStr4 = bgcerqStr3.replace("-","/");
                        pressureReport.bgCsrq = TimeUtil.formatDate4(bgcerqStr4);

                        reportOldYlb.pressure = pressureReport;
                        reportDao.save(reportOldYlb);
                        //------------------------------生成压力表的报告end ------------------------------------
                    }
                } else {
                    //获取测试日期 2020/1/3 15:03:02
                    String xxcsrr = oldMianZhao.getCsrq();
                    String bbcsrq = xxcsrr.replaceAll("\\.000000","");
                    String cccsrq = xxcsrr.replaceAll("-","/");
                    //获取测试日期 2020/1/3 15:03:02
                    long bgCsrq33 = TimeUtil.formatDate4(cccsrq);
                    //如果送检日期的时间戳 减去 实验数据上面的时间戳  两者相差超过20天  就不用生成报告
                    int chazhi = TimeUtil.getOffectDay(sample.jsrqLong,bgCsrq33);
                    int difference = Math.abs(chazhi);
                    //如果差值小于20天 就生成数据
                    if(difference< Config.SJSC_DAY){
                        Report report = new Report();
                        report.bh = sample.bh + "_ylb";
                        //标识编号
                        report.bsbh = sample.bsbh;
                        //设备编号
                        report.sbbh = oldMianZhao.getCpbh();
                        //任务单编号
                        report.rwdbh = sample.rwdbh;
                        //样品类型
                        report.type = report.BG_TYPE_YLB;
                        report.spType = sample.spType;
                        report.setAddTime(TimeUtil.currentTimeMillis());
                        //接收日期时间戳
                        report.jsrqLong = sample.jsrqLong;
                        report.pxzd = sample.pxzd;
                        //压力表表报告结果
                        String ylbcsjgStr = oldMianZhao.getYlbcsjg().trim();
                        //压力表测试(20MPa)
                        String ylbcs20Str = oldMianZhao.getYlbcs20().trim();
                        //压力表测试(10MPa)
                        String ylbcs10Str = oldMianZhao.getYlbcs10().trim();
                        //压力表测试(7MPa)
                        String ylbcs70Str = oldMianZhao.getYlbcs70().trim();

                        //呼吸阻力测试
                        String hxzlcsStr = oldMianZhao.getHxzlcs().trim();
                        //面罩内最大压力
                        String mznzdylStr = oldMianZhao.getMznzdyl().trim();
                        //面罩内最小压力
                        String mznzxylStr = oldMianZhao.getMznzxyl().trim();

                        PressureReport pressureReport = new PressureReport();

                        if ("合格".equals(ylbcsjgStr) && !"".equals(ylbcs20Str) && !"".equals(ylbcs10Str) && !"".equals(ylbcs70Str) &&
                                !"".equals(hxzlcsStr) && !"".equals(mznzdylStr) && !"".equals(mznzxylStr)) {
                            report.reportStatue = 1; //合格
                            pressureReport.jl = "本次压力表校验合格。";
                            //子类状态先设置为0
                            report.failedStart = 0;

                        } else {
                            report.reportStatue = 2; //不合格
                            if ("".equals(ylbcs20Str) && "".equals(ylbcs10Str) && "".equals(ylbcs70Str) && "".equals(hxzlcsStr) && "".equals(mznzdylStr) && "".equals(mznzxylStr)) {
                                pressureReport.jl = "本次压力表未进行校验。";
                                //子类状态先设置为0
                                report.failedStart = 1;
                            } else {
                                pressureReport.jl = "本次压力表校验不合格。";
                                //子类状态先设置为0
                                report.failedStart = 0;
                            }
                        }
                        //报告的进展  待核验
                        report.reportProgress = 1;

                        report.bsbhHrader = sample.bsbhHrader;
                        report.erweima = sample.erweima;
                        report.wtfId = sample.respirator.wtfId;
                        report.wtf = sample.respirator.wtf;

                        report.wtfIdChi = sample.wtfIdChi;
                        report.wtfChi = sample.wtfChi;

                        report.sjr = sample.sjr;
                        report.zzcsId = sample.zzcsId;
                        report.zzcs = sample.zzcs;

                        report.jyrqNian = TimeUtil.formatTime_Year(bgCsrq33);
                        report.jyrqYue = TimeUtil.formatTime_Month(bgCsrq33);
                        report.zfzddhy = 0;
                        report.jyyId = sample.respirator.jcrId;

                        if ("".equals(hxzlcsStr)) {
                            pressureReport.scz1 = "/";
                        } else {
                            pressureReport.scz1 = hxzlcsStr;
                        }
                        if ("".equals(mznzdylStr)) {
                            pressureReport.scz2 = "/";
                        } else {
                            pressureReport.scz2 = mznzdylStr;
                        }
                        if ("".equals(mznzxylStr)) {
                            pressureReport.scz3 = "/";
                        } else {
                            pressureReport.scz3 = mznzxylStr;
                        }


                        if ("".equals(ylbcs20Str)) {
                            pressureReport.byz1 = "/";
                        } else {
                            pressureReport.byz1 = ylbcs20Str;
                        }

                        if ("".equals(ylbcs10Str)) {
                            pressureReport.byz2 = "/";
                        } else {
                            pressureReport.byz2 = ylbcs10Str;
                        }

                        if ("".equals(ylbcs70Str)) {
                            pressureReport.byz3 = "/";
                        } else {
                            pressureReport.byz3 = ylbcs70Str;
                        }

                        //------------------------红蓝图需要的数据start---------
                        HltHxqbean hltHxqbean = new HltHxqbean();
                        if(null != oldMianZhao.getCsrq() && !"".equals(oldMianZhao.getCsrq())){
                            hltHxqbean.hlt_csrq =  oldMianZhao.getCsrq();//测试日期
                        }
                        hltHxqbean.hlt_sydw = sample.respirator.wtf;
                        hltHxqbean.hlt_zzcs = sample.respirator.zzcs;
                        hltHxqbean.hlt_cpxh = sample.respirator.xhgg;
                        hltHxqbean.hlt_cpbh = sample.sbbh;

                        if(null != oldMianZhao.getZjqmxcs() && !"".equals(oldMianZhao.getZjqmxcs())){

                        }
                        if(null !=oldMianZhao.getZjqmxcs() && !"".equals(oldMianZhao.getZjqmxcs())){
                            hltHxqbean.hlt_zjqmx =oldMianZhao.getZjqmxcs();//整机气密性
                        }
                        if(null !=oldMianZhao.getMzxlcs() && !"".equals(oldMianZhao.getMzxlcs())){
                            hltHxqbean.hlt_mzxlcs = oldMianZhao.getMzxlcs();//面罩泄露测试
                        }
                        if(null !=oldMianZhao.getKqjycs() && !"".equals(oldMianZhao.getKqjycs())){
                            hltHxqbean.hlt_kqjycs =oldMianZhao.getKqjycs();//开启静压测试
                        }
                        if(null != oldMianZhao.getYlbcsjg() && !"".equals(oldMianZhao.getYlbcsjg())){
                            hltHxqbean.hlt_ylbjy_str =oldMianZhao.getYlbcsjg();//压力表校验
                        }

                        if(null !=oldMianZhao.getBjqcs() && !"".equals(oldMianZhao.getBjqcs())){
                            hltHxqbean.hlt_bjylcs = oldMianZhao.getBjqcs();
                        }

                        if(null !=oldMianZhao.getHxzlcs() && !"".equals(oldMianZhao.getHxzlcs())){
                            hltHxqbean.hlt_ylz_by1 = oldMianZhao.getHxzlcs();
                        }

                        if(null != oldMianZhao.getMznzdyl() && !"".equals(oldMianZhao.getMznzdyl())){
                            hltHxqbean.hlt_ylz_by2 = oldMianZhao.getMznzdyl();
                        }

                        if(null != oldMianZhao.getMznzxyl() && !"".equals(oldMianZhao.getMznzxyl())){
                            hltHxqbean.hlt_ylz_by3 = oldMianZhao.getMznzxyl();
                        }

                        if(null !=oldMianZhao.getYlbcs20() && !"".equals(oldMianZhao.getYlbcs20())){
                            hltHxqbean.hlt_ylz_sc1 = oldMianZhao.getYlbcs20();
                        }

                        if(null != oldMianZhao.getYlbcs10() && !"".equals(oldMianZhao.getYlbcs10())){
                            hltHxqbean.hlt_ylz_sc2 = oldMianZhao.getYlbcs10();
                        }

                        if(null !=oldMianZhao.getYlbcs70() && !"".equals(oldMianZhao.getYlbcs70())){
                            hltHxqbean.hlt_ylz_sc3 = oldMianZhao.getYlbcs70();
                        }

                        if(null !=oldMianZhao.getMzwg() && !"".equals(oldMianZhao.getMzwg())){
                            hltHxqbean.ms_mz = oldMianZhao.getMzwg();
                        }

                        if(null !=oldMianZhao.getBjbdwg() && !"".equals(oldMianZhao.getBjbdwg())){
                            hltHxqbean.ms_bjsd = oldMianZhao.getBjbdwg();
                        }

                        if(null !=oldMianZhao.getQpwg() && !"".equals(oldMianZhao.getQpwg())){
                            hltHxqbean.ms_qp = oldMianZhao.getQpwg();
                        }

                        if(null !=oldMianZhao.getDybjqwg() && !"".equals(oldMianZhao.getDybjqwg())){
                            hltHxqbean.ms_dyljg = oldMianZhao.getDybjqwg();
                        }

                        if(null !=oldMianZhao.getJgwg() && !"".equals(oldMianZhao.getJgwg())){
                            hltHxqbean.ms_jg = oldMianZhao.getJgwg();
                        }



                        if(null!= oldMianZhao.getYlzdz100() && !"".equals(oldMianZhao.getYlzdz100())){
                            hltHxqbean.hlt_zl100_d = oldMianZhao.getYlzdz100();
                        }
                        if(null!= oldMianZhao.getYzzxz100() && !"".equals(oldMianZhao.getYzzxz100())){
                            hltHxqbean.hlt_zl100_x = oldMianZhao.getYzzxz100();
                        }

                        if(null!= oldMianZhao.getMzylcs100() && !"".equals(oldMianZhao.getMzylcs100())){
                            hltHxqbean.hlt_zl100_jg = oldMianZhao.getMzylcs100();
                        }

                        if(null!= oldMianZhao.getYlzdz50() && !"".equals( oldMianZhao.getYlzdz50())){
                            hltHxqbean.hlt_zl50_d = oldMianZhao.getYlzdz50();
                        }

                        if(null!= oldMianZhao.getYlzxz50() && !"".equals( oldMianZhao.getYlzxz50())){
                            hltHxqbean.hlt_zl50_x = oldMianZhao.getYlzxz50();
                        }
                        if(null!= oldMianZhao.getMzylcs50() && !"".equals( oldMianZhao.getMzylcs50())){
                            hltHxqbean.hlt_zl50_jg = oldMianZhao.getMzylcs50();
                        }

                        report.hltImg1 ="";
                        report.hltImg2="";
                        pressureReport.khxinBean = hltHxqbean;
                        //------------------------红蓝图需要的数据end---------


                        if(null!=mOtherInput){
                            //检验单位授权号
                            pressureReport.jydwsqh = mOtherInput.ylb_jydwsqh;
                        }else{
                            //检验单位授权号
                            pressureReport.jydwsqh = Config.YLB_JTDWSQH;
                        }

                        pressureReport.jyyId = sample.respirator.jcrId;
                        pressureReport.jyy = sample.respirator.jcr;
                        pressureReport.jyrq = sample.respirator.sjri;
                        //获取测试日期 2020/1/3 15:03:02
                        String bgcerqStr = oldMianZhao.getCsrq();
                        //报告的测试日期
                        String  bgcerqStr2 =StringUtils.replaceXqn(bgcerqStr);
                        String bgcerqStr3 = bgcerqStr2.replace(".000000","");
                        String bgcerqStr4 = bgcerqStr3.replace("-","/");
                        pressureReport.bgCsrq = TimeUtil.formatDate4(bgcerqStr4);

                        report.pressure = pressureReport;
                        reportDao.save(report);
                    }

                    //------------------------------生成压力表的报告end ------------------------------------
                }
            }
        } catch (Exception e) {

        }
        return resultMsg;
    }




    /**
     * 呼吸器面罩 （新机器的）
     *
     * @param request
     * @param data
     * @return
     */
    public ResultMsg uploadMzNew(HttpServletRequest request, String data) {
        ResultMsg resultMsg = new ResultMsg();
        try {
            OtherInput mOtherInput = otherInputDao.getOtherInput();
            KhxinBean khxinBean = JSON.parseObject(data, KhxinBean.class);
            if (null == khxinBean) {
                resultMsg.setCode(ResultMsg.ERROR);
                return resultMsg;
            }
            //根据设备编号查询样品信息
            Sernums sernums = khxinBean.sernums;
            if (null == sernums) {
                resultMsg.setCode(ResultMsg.ERROR);
                return resultMsg;
            }



            //根据设备编号查询样品信息
            Sample sample = mSampleDao.getPcSampleBySbbh(sernums.getSernum());
            if (null != sample) {

                //如果当前的 样品没有分配 检验员 就不生成报告
                if(null ==sample.respirator.jcrId || "".equals(sample.respirator.jcrId)){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }

                //如果没有整机气密性和 报警声强就不生成 报告
                if("".equals(sample.respirator.zjqmx) || "".equals(sample.respirator.bjsq)){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }

                if(sample.respirator.sfjy ==-1){
                    resultMsg.setCode(ResultMsg.ERROR);
                    return resultMsg;
                }

                //先 查询这条数据有没有生成 呼吸器的报告
                Report reportOldHxq = reportDao.getReportBybsbhAdType(sample.bsbh, 1);
                if(null !=reportOldHxq && reportOldHxq.sbbh.equals(sernums.getSernum())){
                    Date date = khxinBean.headers.getDatetime();
                    if(date.getTime()> reportOldHxq.respirator.bgCsrq){
                        //------------------------------生成面罩的报告start ----------------------------------
                        reportOldHxq.bh = sample.bh + "_mz";
                        //标识编号
                        reportOldHxq.bsbh = sample.bsbh;
                        //任务单编号
                        reportOldHxq.rwdbh = sample.rwdbh;
                        //设备编号
                        reportOldHxq.sbbh = sernums.getSernum();
                        //样品类型
                        reportOldHxq.type = reportOldHxq.BG_TYPE_HXQ;
                        reportOldHxq.spType = sample.spType;
                        //设置短信的发送状态
                        reportOldHxq.isSendSMS = 0;
                        reportOldHxq.pxzd = sample.pxzd;
                        //接收日期时间戳
                        reportOldHxq.jsrqLong = sample.jsrqLong;

                        //面罩泄露测试小于-25Pa 检验结果
                        String mzxlceStrJyjg = "";
                        String mzxlceStrJyjg_hlt="";
                        //面罩泄露测试小于-25Pa 单项判定
                        String mzxlceStrDxpd = "";

                        //压力表1min 内的下降不大于2Mpa 检验结果
                        String zjqmxStrJyjg = "";
                        //压力表1min 内的下降不大于2Mpa 单项判刑
                        String zjqmxStrDxpd = "";

                        //静态压力 检验结果
                        String jtylStrJyjg = "";
                        //静态压力 单项判定
                        String jtylStrDxpd = "";

                        //报警压力 检验结果
                        String bjyaStrJyjg = "";
                        //报警压力 单项判定
                        String bjyaStrDxpd = "";

                        //报警声强 检验结果
                        String bjsqStrJyjg = "";
                        //报警声强 单项判定
                        String bjsqStrDxpd = "";

                        //报警声强
                        String bjsqVal = sample.respirator.bjsq;
                        if("/".equals(bjsqVal)){
                            bjsqStrDxpd = "不合格";
                        }else{
                            double bjsqDoub = Double.parseDouble(bjsqVal);
                            bjsqStrJyjg = bjsqVal + "";
                            if (bjsqDoub < 90) {
                                bjsqStrDxpd = "不合格";
                            } else {
                                bjsqStrDxpd = "合格";
                            }
                        }

                        //压力试验类
                        List<Pressuretests> pressuretestsList = khxinBean.pressuretests;
                        for (Pressuretests pressuretests : pressuretestsList) {
                            if (null != pressuretests.getTesttype()) {
                                switch (pressuretests.getTesttype()) {
                                    case 1:  //面具泄露
                                        if(pressuretests.getPress() != null){
                                            if((pressuretests.getPress()*10)>0){
                                                mzxlceStrJyjg_hlt = "-" + (pressuretests.getPress() * 100 + "Pa");
                                            }else{
                                                mzxlceStrJyjg_hlt = (pressuretests.getPress()* 100 + "Pa");
                                            }
                                            mzxlceStrJyjg="见附页";
                                        }else{
                                            mzxlceStrJyjg ="";
                                        }

                                        if (pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            mzxlceStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            mzxlceStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            mzxlceStrDxpd = "不合格";
                                        }
                                        break;
                                    case 2:  //中压更改
                                        break;
                                    case 3: //中压更改
                                        break;
                                    case 4: //高压力泄露   ---整机气密性
                                        if(null == pressuretests.getPress()){
                                            zjqmxStrJyjg="";
                                        }else{
                                            zjqmxStrJyjg = pressuretests.getPress() / 10 + "";
                                        }

                                        if (null == pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            zjqmxStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            zjqmxStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            zjqmxStrDxpd = "不合格";
                                        }

                                        break;
                                    case 5: //呼气压力
                                        break;
                                    case 6: //静态面具压力
                                        if(null  == pressuretests.getPress()){
                                            jtylStrJyjg = "";
                                        }else{
                                            float nfnf = pressuretests.getPress() ;
                                            int dede = (int) (nfnf *100) ;
                                            jtylStrJyjg = dede + "Pa";
                                        }
                                        if (null ==pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            jtylStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            jtylStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            jtylStrDxpd = "不合格";
                                        }

                                        break;
                                    case 7: //第一次呼吸启动
                                        break;
                                    case 8: //静态中压
                                        break;
                                    case 9: //动态面具压力FP


                                        break;
                                    case 10: //动态中压
                                        break;
                                    case 11: //旁路流量
                                        break;
                                    case 12: //旁路压力
                                        break;
                                    case 13: //安全阀
                                        break;
                                    case 14: //报警哨
                                        //
                                        if(null == pressuretests.getPress()){
                                            bjyaStrJyjg="";
                                        }else{
                                            bjyaStrJyjg = pressuretests.getPress() / 10 + "MPa";
                                        }
                                        if (null ==pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            bjyaStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            bjyaStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            bjyaStrDxpd = "不合格";
                                        }
                                        break;
                                    case 15: // 振铃
                                        break;

                                }
                            }
                        }

                        //呼吸阻力100L/min  单项判定
                        String hxzl100_dxpd = "";
                        //呼吸阻力100L/min 最小值
                        String hxzl100_x = "";
                        //呼吸阻力100L/min  最大值
                        String hxzl100_d = "";
                        byte[] hxzl100_img;

                        //呼吸阻力50L/min  单项判定
                        String hxzl50_dxpd = "";
                        //呼吸阻力100L/min 最小值
                        String hxzl50_x = "";
                        //呼吸阻力100L/min  最大值
                        String hxzl50_d = "";

                        byte[] hxzl150_img;


                        List<Breathingtests> breathingtests = khxinBean.breathingtests;
                        for (Breathingtests breathingtests1 : breathingtests) {
                            if (breathingtests1.getTesttype() == 9) {
                                if (breathingtests1.getTestorder() == 1) { //呼吸阻力 50L/min
                                    if (breathingtests1.getResult() == 1) { //合格
                                        hxzl50_dxpd = "合格";
                                    } else {  //不合格
                                        hxzl50_dxpd = "不合格";
                                    }
                                    if(null ==breathingtests1.getBmin()){
                                        hxzl50_x="";
                                    }else{
                                        hxzl50_x = ((int)(breathingtests1.getBmin() * 100)) + "";
                                    }

                                    if(null == breathingtests1.getBmax()){
                                        hxzl50_d = "";
                                    }else{
                                        hxzl50_d = ((int)(breathingtests1.getBmax() * 100)) + "";
                                    }
                                    //图片
                                    hxzl150_img = breathingtests1.getGraph();
                                    // if(null != hxzl150_img){
                                    //     boolean isok =  saveImageToLoacl(hxzl150_img,sample.bsbh+"_m50.png");
                                    //     if(isok){
                                    //         reportOldHxq.hltImg1 = "/up/fxq/"+sample.bsbh+"_m50.png";
                                    //     }else{
                                    //         reportOldHxq.hltImg1 ="";
                                    //     }
                                    // }else{
                                    //     reportOldHxq.hltImg1 ="";
                                    // }

                                    if(null != hxzl150_img){
                                        String  zhstr = saveImageToLoacl150(hxzl150_img,sample);
                                        reportOldHxq.hltImg1 = zhstr;
                                    }else{
                                        reportOldHxq.hltImg1 ="";
                                    }


                                } else if (breathingtests1.getTestorder() == 2) {//呼吸阻力 100L/min
                                    if (breathingtests1.getResult() == 1) { //合格
                                        hxzl100_dxpd = "合格";
                                    } else {  //不合格
                                        hxzl100_dxpd = "不合格";
                                    }
                                    if(null ==breathingtests1.getBmin()){
                                        hxzl100_x = "";
                                    }else{
                                        hxzl100_x = ((int)(breathingtests1.getBmin() * 100)) + "";
                                    }

                                    if(null ==breathingtests1.getBmax()){
                                        hxzl100_d ="";
                                    }else{
                                        hxzl100_d = ((int)(breathingtests1.getBmax() * 100)) + "";
                                    }
                                    hxzl100_img = breathingtests1.getGraph();
                                    // if(null != hxzl100_img){
                                    //     boolean isok =  saveImageToLoacl(hxzl100_img,sample.bsbh+"_m100.png");
                                    //    if(isok){
                                    //         reportOldHxq.hltImg2 ="/up/fxq/"+sample.bsbh+"_m100.png";
                                    //     }else{
                                    //           reportOldHxq.hltImg2 ="";
                                    //      }
                                    //  }else{
                                    //     reportOldHxq.hltImg2 ="";
                                    //}

                                    if(null != hxzl100_img){
                                        String zhstr100 = saveImageToLoacl100(hxzl100_img,sample);
                                        reportOldHxq.hltImg2 = zhstr100;
                                    }else{
                                        reportOldHxq.hltImg2 ="";
                                    }


                                }
                            }
                        }
                        if ("".equals(mzxlceStrDxpd) || "".equals(zjqmxStrDxpd) || "".equals(jtylStrDxpd) || "".equals(bjyaStrDxpd)
                                || "".equals(bjsqStrDxpd) || "".equals(hxzl50_dxpd) || "".equals(hxzl100_dxpd)) {
                            reportOldHxq.reportStatue = 2; //不合格
                        } else {
                            //如果一下任意一个包含了 不合格  整个报告算不合格
                            if ("合格".equals(mzxlceStrDxpd) && "合格".equals(zjqmxStrDxpd) && "合格".equals(jtylStrDxpd) &&
                                    "合格".equals(bjyaStrDxpd) && "合格".equals(bjsqStrDxpd) && "合格".equals(hxzl50_dxpd) && "合格".equals(hxzl100_dxpd)) {
                                reportOldHxq.reportStatue = 1; //合格
                            } else {
                                reportOldHxq.reportStatue = 2; //不合格
                            }
                        }
                        //报告的进展  待核验
                        reportOldHxq.reportProgress = 1;
                        //子类状态先设置为0
                        reportOldHxq.failedStart = 0;
                        reportOldHxq.bsbhHrader = sample.bsbhHrader;
                        reportOldHxq.erweima = sample.erweima;
                        reportOldHxq.wtfId = sample.respirator.wtfId;
                        reportOldHxq.wtf = sample.respirator.wtf;

                        reportOldHxq.wtfIdChi = sample.wtfIdChi;
                        reportOldHxq.wtfChi = sample.wtfChi;

                        reportOldHxq.sjr = sample.sjr;
                        reportOldHxq.zzcsId = sample.zzcsId;
                        reportOldHxq.zzcs = sample.zzcs;


                        reportOldHxq.zfzddhy = 0;
                        reportOldHxq.jyyId = sample.respirator.jcrId;



                        RespiratorReport respiratorReport = new RespiratorReport();
                        respiratorReport.bh = sample.bh;
                        respiratorReport.wtfId = sample.respirator.wtfId;
                        respiratorReport.wtf = sample.respirator.wtf;
                        respiratorReport.sjrId = sample.respirator.sjrId;
                        respiratorReport.sjr = sample.respirator.sjr;
                        respiratorReport.ypmc = "正压式空气呼吸器";
                        respiratorReport.zzcsId = sample.respirator.zzcsId;
                        respiratorReport.zzcs = sample.respirator.zzcs;
                        respiratorReport.xhgg = sample.respirator.xhgg;
                        respiratorReport.ccbh = sample.respirator.ccbh;
                        if (reportOldHxq.reportStatue == 2) {
                            respiratorReport.jyjl = "不合格";
                        }
                        //如果没有代表批量 或者为空
                        if(null ==sample.respirator.dbpl || "".equals(sample.respirator.dbpl)){
                            respiratorReport.dbpl="";
                        }else{
                            respiratorReport.dbpl=sample.respirator.dbpl;
                        }
                        respiratorReport.fzdw = "";
                        respiratorReport.pzrId = "";
                        respiratorReport.pzr = "";
                        respiratorReport.hyyId = "";
                        respiratorReport.hyy = "";

                        respiratorReport.jyyId = sample.respirator.jcrId;
                        respiratorReport.jyy = sample.respirator.jcr;

                        if(mOtherInput==null){
                            respiratorReport.jydwsqh = mOtherInput.mz_jydwsqh;
                        }else{
                            respiratorReport.jydwsqh =Config.MZ_JTDWSQH;
                        }

                        //计算有效期
                        long year1 = TimeUtil.getDateBeforeYear(date, 1);
                        reportOldHxq.jyrqNian = TimeUtil.formatTime_Year(date.getTime());
                        reportOldHxq.jyrqYue = TimeUtil.formatTime_Month(date.getTime());
                        respiratorReport.yxrq = TimeUtil.formatTime_tow(year1);
                        reportOldHxq.xcjyrq = year1;
                        respiratorReport.jyrq = TimeUtil.formatTime_tow(date.getTime());
                        respiratorReport.sjrq = sample.respirator.sjri;
                        reportOldHxq.setAddTime(TimeUtil.currentTimeMillis());
                        //设置匹配气瓶的信息
                        respiratorReport.qpbsh = sample.respirator.qpbsh;

                        respiratorReport.nr_ypmc = "正压式空气呼吸器";
                        respiratorReport.nr_syrId = "";
                        respiratorReport.nr_syr = sample.respirator.sjr;
                        respiratorReport.nr_ypsl = 1;
                        respiratorReport.nr_ypztms = "完好";
                        respiratorReport.nr_sb = sample.respirator.sbstr;
//                        if(sample.respirator.sfxp == 1){
//                            respiratorReport.nr_ypdj = "新品";
//                        }else{
//                            respiratorReport.nr_ypdj = "旧品";
//                        }
                        if(sample.respirator.xjpType ==0 ||sample.respirator.xjpType ==1){
                            respiratorReport.nr_ypdj = "旧品";
                        }else{
                            respiratorReport.nr_ypdj = "新品";
                        }
                        //如果是抽检
                        if(sample.spType ==1){
                            respiratorReport.nr_jylx = "委托检验";
                        }else{
                            respiratorReport.nr_jylx = "质量抽检";
                        }
                        respiratorReport.nr_scrq = sample.respirator.scrq;
                        respiratorReport.nr_dyrq = sample.respirator.sjri;
                        respiratorReport.nr_ybhph = sample.sbbh;

                        String qunm = sample.bsbh;
                        String[] qnmmm = qunm.split("DQFJ");
                        respiratorReport.nr_ypjsbh = qnmmm[1];

                        respiratorReport.nr_jyxm = "5项";
                        respiratorReport.nr_jyyj = "AQ/T6110-2012《工业空气呼吸器安全使用维护管理规范》";
                        respiratorReport.nr_jyjl = "依据标准AQ/T6110-2012《工业空气呼吸器安全使用维护管理规范》检查，该样品索检项目符合要求。";
                        respiratorReport.nr_jfrq = "";
                        respiratorReport.nr_jybgzyz = "";
                        respiratorReport.nr_bz = "";

                        respiratorReport.nr_wg_jszb = "符合AQ/T6110-2012表 定期技术检测外观检查表要求";
                        respiratorReport.nr_wg_jyjg = "";
                        respiratorReport.nr_wg_dxpd = "";

                        respiratorReport.nr_mz_jszb = "面罩泄漏测试小于-25Pa";
                        respiratorReport.nr_mz_jyjg = mzxlceStrJyjg;
                        respiratorReport.nr_mz_dxpd = mzxlceStrDxpd;


                        respiratorReport.nr_ylb_jszb = "压力表1min内下降不大于2MPa";
                        if("/".equals(zjqmxStrJyjg)){
                            respiratorReport.nr_ylb_jyjg = "";
                        }else{
                            respiratorReport.nr_ylb_jyjg = zjqmxStrJyjg;
                        }

                        respiratorReport.nr_ylb_dxpd = zjqmxStrDxpd;


                        respiratorReport.nr_jtyl_jszb = "（0~500）Pa并小于呼吸阀开启压力";
                        respiratorReport.nr_jtyl_jyjg = jtylStrJyjg;
                        respiratorReport.nr_jtyl_dxpd = jtylStrDxpd;


                        respiratorReport.nr_bjyl_jszb = "（5.5±0.5）MPa";
                        respiratorReport.nr_bjyl_jyjg = bjyaStrJyjg;
                        respiratorReport.nr_bjyl_dxpd = bjyaStrDxpd;

                        respiratorReport.nr_bjsq_jszb = "不小于90dB(A)";
                        respiratorReport.nr_bjsq_jyjg = bjsqStrJyjg + "dB(A)";
                        respiratorReport.nr_bjsq_dxpd = bjsqStrDxpd;
                        //100L/min
                        respiratorReport.nr_hxzl_mc1 = "气瓶额定压力至2MPa呼吸器频率40次/min呼吸流量100L/min";
                        respiratorReport.nr_hxzl_jszb1 = "吸气阻力不大于500Ma 呼气阻力不大于1000Pa";
                        respiratorReport.nr_hxzl_jyjg1_x = "吸气阻力：" + hxzl100_x + "Pa";
                        respiratorReport.nr_hxzl_jyjg1_d = "呼气阻力：" + hxzl100_d + "Pa";
                        respiratorReport.nr_hxzl_dxpd1 = hxzl100_dxpd;
                        //50L/min
                        respiratorReport.nr_hxzl_mc2 = "气瓶额定压力至2MPa至1MPa呼吸器频率40次/min呼吸流量100L/min";
                        respiratorReport.nr_hxzl_jszb2 = "吸气阻力不大于500Ma 呼气阻力不大于700Pa";
                        respiratorReport.nr_hxzl_jyjg2_x = "吸气阻力：" + hxzl50_x + "Pa";
                        respiratorReport.nr_hxzl_jyjg2_d = "呼气阻力：" + hxzl50_d + "Pa";
                        respiratorReport.nr_hxzl_dxpd2 = hxzl50_dxpd;
                        Date date2 = khxinBean.headers.getDatetime();
                        //报告的测试日期
                        respiratorReport.bgCsrq = date2.getTime();

                        HltHxqbean hltHxqbean = new HltHxqbean();
                        if(null !=khxinBean.headers && null !=khxinBean.headers.getDatetime()){
                            //测试日期
                            hltHxqbean.hlt_csrq =TimeUtil.formatTime_three(khxinBean.headers.getDatetime().getTime());
                        }
                        //使用单位
                        hltHxqbean. hlt_sydw = sample.respirator.wtf;
                        //制造厂商
                        hltHxqbean.hlt_zzcs = sample.respirator.zzcs;
                        //产品信号
                        hltHxqbean.hlt_cpxh = sample.respirator.xhgg;
                        //产品编号
                        hltHxqbean.hlt_cpbh = sample.bsbh;
                        //整机气密性
                        hltHxqbean.hlt_zjqmx =zjqmxStrDxpd+" "+zjqmxStrJyjg;
                        //面罩泄露测试
                        hltHxqbean.hlt_mzxlcs =mzxlceStrDxpd+ " "+mzxlceStrJyjg_hlt;
                        //开启/静压测试
                        hltHxqbean.hlt_kqjycs = jtylStrDxpd+ "" +jtylStrJyjg;
                        //报警压力测试
                        hltHxqbean.hlt_bjylcs = bjyaStrDxpd+ " "+bjyaStrJyjg;
                        if(null != khxinBean.gaugetests){
                            Gaugetests gaug =  khxinBean.gaugetests;
                            //压力表校验  合格：不合格
                            hltHxqbean.hlt_ylbjy_str = gaug.getResult() ==1?"合格":"不合格";
                            //实测值1
                            hltHxqbean.hlt_ylz_sc1 = "10 Mpa";
                            //实测值2
                            hltHxqbean.hlt_ylz_sc2 = "15 Mpa";
                            //实测值3
                            hltHxqbean.hlt_ylz_sc3 = "20 Mpa";

                            DecimalFormat df   =new   java.text.DecimalFormat("#.0");
                            df.setRoundingMode(RoundingMode.FLOOR);//不四舍五入


                            double hlt_ylz_d11 = ((double)gaug.getPr3()/10);
                            double hlt_ylz_d22 = ((double)gaug.getPr2()/10);
                            double hlt_ylz_d33 = ((double)gaug.getPr1()/10);

                            if(hlt_ylz_d11== 0){
                                //表压值1
                                hltHxqbean.hlt_ylz_by1 = "";
                            }else{
                                //表压值1
                                hltHxqbean.hlt_ylz_by1 = df.format(hlt_ylz_d11)+"Mpa";
                            }
                            if(hlt_ylz_d22== 0){
                                //表压值2
                                hltHxqbean.hlt_ylz_by2 = "";
                            }else{
                                //表压值2
                                hltHxqbean.hlt_ylz_by2 = df.format(hlt_ylz_d22)+"Mpa";
                            }
                            if(hlt_ylz_d33 == 0){
                                //表压值3
                                hltHxqbean.hlt_ylz_by3 = "";
                            }else{
                                //表压值3
                                hltHxqbean.hlt_ylz_by3 = df.format(hlt_ylz_d33)+"Mpa";
                            }
                            //呼吸阻力50L/min
                            hltHxqbean.hlt_zl50_x =hxzl50_x;
                            hltHxqbean.hlt_zl50_d=  hxzl50_d;
                            hltHxqbean.hlt_zl50_jg = hxzl50_dxpd;
                            //呼吸阻力100L/min
                            hltHxqbean.hlt_zl100_x = hxzl100_x;
                            hltHxqbean.hlt_zl100_d = hxzl100_d;
                            hltHxqbean.hlt_zl100_jg = hxzl100_dxpd;
                        }

                        if(null != khxinBean.visualtests){
                            Visualtests vv=  khxinBean.visualtests;
                            if(vv.getFacepiece() == 1){
                                hltHxqbean.ms_mz ="合格";
                            }else if(vv.getFacepiece() == 2){
                                hltHxqbean.ms_mz ="不合格";
                            }else{
                                hltHxqbean.ms_mz ="";
                            }
                            if(vv.getCarrier() == 1){
                                hltHxqbean.ms_bjsd ="合格";
                            } else if(vv.getCarrier() == 2){
                                hltHxqbean.ms_bjsd ="不合格";
                            }else{
                                hltHxqbean.ms_bjsd ="";
                            }

                            if(vv.getCylinder() == 1){
                                hltHxqbean.ms_qp ="合格";
                            } else if(vv.getCylinder() == 2){
                                hltHxqbean.ms_qp ="不合格";
                            }else{
                                hltHxqbean.ms_qp ="";
                            }

                            if(vv.getWarning() == 1){
                                hltHxqbean.ms_dyljg ="合格";
                            } else if(vv.getWarning() == 2){
                                hltHxqbean.ms_dyljg ="不合格";
                            }else{
                                hltHxqbean.ms_dyljg ="";
                            }
                            if(vv.getHoses() == 1){
                                hltHxqbean.ms_jg ="合格";
                            } else if(vv.getHoses() == 2){
                                hltHxqbean.ms_jg ="不合格";
                            }else{
                                hltHxqbean.ms_jg ="";
                            }
                        }

                        if(null !=khxinBean.headers){
                            //测试人员
                            String hlt_csry =khxinBean.headers.getUsername();
                            hltHxqbean.hlt_csry = hlt_csry;
                        }
                        respiratorReport.khxinBean= hltHxqbean;
                        reportOldHxq.respirator = respiratorReport;
                        reportDao.save(reportOldHxq);
                        //------------------------------生成面罩的报告end ------------------------------------

                    }
                }else{

                    if(null !=khxinBean.headers.getDatetime()){
                        Date datem2 = khxinBean.headers.getDatetime();
                        //如果送检日期的时间戳 减去 实验数据上面的时间戳  两者相差超过20天  就不用生成报告
                        int chazhi = TimeUtil.getOffectDay(sample.jsrqLong,datem2.getTime());
                        int difference = Math.abs(chazhi);
                        //如果差值小于20天 就生成数据
                        if(difference< Config.SJSC_DAY){
                            Report reportNew = new Report();
                            //------------------------------生成面罩的报告start ----------------------------------
                            reportNew.bh = sample.bh + "_mz";
                            //标识编号
                            reportNew.bsbh = sample.bsbh;
                            //任务单编号
                            reportNew.rwdbh = sample.rwdbh;
                            //设备编号
                            reportNew.sbbh = sernums.getSernum();
                            //样品类型
                            reportNew.type = reportNew.BG_TYPE_HXQ;
                            reportNew.spType = sample.spType;
                            //设置短信的发送状态
                            reportNew.isSendSMS = 0;
                            //接收日期时间戳
                            reportNew.jsrqLong = sample.jsrqLong;
                            reportNew.pxzd = sample.pxzd;
                            //面罩泄露测试小于-25Pa 检验结果
                            String mzxlceStrJyjg = "";

                            //面罩泄露测试小于-25Pa 检验结果
                            String mzxlceStrJyjg_hlt = "";

                            //面罩泄露测试小于-25Pa 单项判定
                            String mzxlceStrDxpd = "";

                            //压力表1min 内的下降不大于2Mpa 检验结果
                            String zjqmxStrJyjg = "";
                            //压力表1min 内的下降不大于2Mpa 单项判刑
                            String zjqmxStrDxpd = "";

                            //静态压力 检验结果
                            String jtylStrJyjg = "";
                            //静态压力 单项判定
                            String jtylStrDxpd = "";

                            //报警压力 检验结果
                            String bjyaStrJyjg = "";
                            //报警压力 单项判定
                            String bjyaStrDxpd = "";

                            //报警声强 检验结果
                            String bjsqStrJyjg = "";
                            //报警声强 单项判定
                            String bjsqStrDxpd = "";

                            //报警声强
                            String bjsqVal = sample.respirator.bjsq;

                            if("/".equals(bjsqVal)){
                                bjsqStrDxpd = "不合格";
                            }else{
                                double bjsqDoub = Double.parseDouble(bjsqVal);
                                bjsqStrJyjg = bjsqVal + "";
                                if (bjsqDoub < 90) {
                                    bjsqStrDxpd = "不合格";
                                } else {
                                    bjsqStrDxpd = "合格";
                                }
                            }
                            //压力试验类
                            List<Pressuretests> pressuretestsList = khxinBean.pressuretests;
                            for (Pressuretests pressuretests : pressuretestsList) {
                                if (null != pressuretests.getTesttype()) {
                                    switch (pressuretests.getTesttype()) {
                                        case 1:  //面具泄露
                                            if(pressuretests.getPress() != null){
                                                if((pressuretests.getPress()*10)>0){
                                                    mzxlceStrJyjg_hlt = "-" + (pressuretests.getPress() * 100 + "Pa");
                                                }else{
                                                    mzxlceStrJyjg_hlt = (pressuretests.getPress()* 100 + "Pa");
                                                }
                                                mzxlceStrJyjg ="见附页";
                                            }else{
                                                mzxlceStrJyjg ="";
                                            }

                                            if (pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                                mzxlceStrDxpd = "";
                                            } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                                mzxlceStrDxpd = "合格";
                                            } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                                mzxlceStrDxpd = "不合格";
                                            }
                                            break;
                                        case 2:  //中压更改
                                            break;
                                        case 3: //中压更改
                                            break;
                                        case 4: //高压力泄露   ---整机气密性
                                            if(null == pressuretests.getPress()){
                                                zjqmxStrJyjg="";
                                            }else{
                                                zjqmxStrJyjg = pressuretests.getPress() / 10 + "";
                                            }

                                            if (null == pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                                zjqmxStrDxpd = "";
                                            } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                                zjqmxStrDxpd = "合格";
                                            } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                                zjqmxStrDxpd = "不合格";
                                            }

                                            break;
                                        case 5: //呼气压力
                                            break;
                                        case 6: //静态面具压力
                                            if(null  == pressuretests.getPress()){
                                                jtylStrJyjg = "";
                                            }else{
                                                float nfnf = pressuretests.getPress() ;
                                                int dede = (int) (nfnf *100) ;
                                                jtylStrJyjg = dede + "Pa";
                                            }
                                            if (null ==pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                                jtylStrDxpd = "";
                                            } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                                jtylStrDxpd = "合格";
                                            } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                                jtylStrDxpd = "不合格";
                                            }

                                            break;
                                        case 7: //第一次呼吸启动
                                            break;
                                        case 8: //静态中压
                                            break;
                                        case 9: //动态面具压力FP


                                            break;
                                        case 10: //动态中压
                                            break;
                                        case 11: //旁路流量
                                            break;
                                        case 12: //旁路压力
                                            break;
                                        case 13: //安全阀
                                            break;
                                        case 14: //报警哨
                                            //
                                            if(null == pressuretests.getPress()){
                                                bjyaStrJyjg="";
                                            }else{
                                                DecimalFormat df   =new   java.text.DecimalFormat("#.00");
                                                df.setRoundingMode(RoundingMode.FLOOR);//不四舍五入

                                                double xxx1 = pressuretests.getPress() / 10;
                                                String xxx2= df.format(xxx1);

                                                bjyaStrJyjg = xxx2 + "MPa";
                                            }
                                            if (null ==pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                                bjyaStrDxpd = "";
                                            } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                                bjyaStrDxpd = "合格";
                                            } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                                bjyaStrDxpd = "不合格";
                                            }
                                            break;
                                        case 15: // 振铃
                                            break;

                                    }
                                }
                            }
                            //呼吸阻力100L/min  单项判定
                            String hxzl100_dxpd = "";
                            //呼吸阻力100L/min 最小值
                            String hxzl100_x = "";
                            //呼吸阻力100L/min  最大值
                            String hxzl100_d = "";
                            byte[] hxzl100_img;

                            //呼吸阻力50L/min  单项判定
                            String hxzl50_dxpd = "";
                            //呼吸阻力100L/min 最小值
                            String hxzl50_x = "";
                            //呼吸阻力100L/min  最大值
                            String hxzl50_d = "";

                            byte[] hxzl150_img;

                            List<Breathingtests> breathingtests = khxinBean.breathingtests;
                            for (Breathingtests breathingtests1 : breathingtests) {
                                if (breathingtests1.getTesttype() == 9) {
                                    if (breathingtests1.getTestorder() == 1) { //呼吸阻力 50L/min
                                        if (breathingtests1.getResult() == 1) { //合格
                                            hxzl50_dxpd = "合格";
                                        } else {  //不合格
                                            hxzl50_dxpd = "不合格";
                                        }
                                        if(null ==breathingtests1.getBmin()){
                                            hxzl50_x="";
                                        }else{
                                            hxzl50_x = ((int)(breathingtests1.getBmin() * 100)) + "";
                                        }

                                        if(null == breathingtests1.getBmax()){
                                            hxzl50_d = "";
                                        }else{
                                            hxzl50_d = ((int)(breathingtests1.getBmax() * 100)) + "";
                                        }
                                        //图片
                                        hxzl150_img = breathingtests1.getGraph();
                                        //if(null != hxzl150_img){
                                        //  boolean isok =  saveImageToLoacl(hxzl150_img,sample.bsbh+"_m50.png");
                                        //  if(isok){
                                        //      reportNew.hltImg1 = "/up/fxq/"+sample.bsbh+"_m50.png";
                                        //  }else{
                                        //       reportNew.hltImg1 ="";
                                        //  }
                                        //
                                        // }else{
                                        //    reportNew.hltImg1 ="";
                                        // }


                                        if(null != hxzl150_img){
                                            String  zhstr = saveImageToLoacl150(hxzl150_img,sample);
                                            reportNew.hltImg1 = zhstr;
                                        }else{
                                            reportNew.hltImg1 ="";
                                        }

                                    } else if (breathingtests1.getTestorder() == 2) {//呼吸阻力 100L/min
                                        if (breathingtests1.getResult() == 1) { //合格
                                            hxzl100_dxpd = "合格";
                                        } else {  //不合格
                                            hxzl100_dxpd = "不合格";
                                        }
                                        if(null ==breathingtests1.getBmin()){
                                            hxzl100_x = "";
                                        }else{
                                            hxzl100_x = ((int)(breathingtests1.getBmin() * 100)) + "";
                                        }

                                        if(null ==breathingtests1.getBmax()){
                                            hxzl100_d ="";
                                        }else{
                                            hxzl100_d = ((int)(breathingtests1.getBmax() * 100)) + "";
                                        }
                                        hxzl100_img = breathingtests1.getGraph();
                                        //if(null != hxzl100_img){
                                        //    boolean isok =  saveImageToLoacl(hxzl100_img,sample.bsbh+"_m100.png");
                                        //    if(isok){
                                        //        reportNew.hltImg2 ="/up/fxq/"+sample.bsbh+"_m100.png";
                                        //    }else{
                                        //        reportNew.hltImg2 ="";
                                        //    }
                                        //}else{
                                        //    reportNew.hltImg2 ="";
                                        // }

                                        if(null != hxzl100_img){
                                            String zhstr100 = saveImageToLoacl100(hxzl100_img,sample);
                                            reportNew.hltImg2 = zhstr100;
                                        }else{
                                            reportNew.hltImg2 ="";
                                        }

                                    }
                                }
                            }
                            if ("".equals(mzxlceStrDxpd) || "".equals(zjqmxStrDxpd) || "".equals(jtylStrDxpd) || "".equals(bjyaStrDxpd)
                                    || "".equals(bjsqStrDxpd) || "".equals(hxzl50_dxpd) || "".equals(hxzl100_dxpd)) {
                                reportNew.reportStatue = 2; //不合格
                            } else {
                                //如果一下任意一个包含了 不合格  整个报告算不合格
                                if ("合格".equals(mzxlceStrDxpd) && "合格".equals(zjqmxStrDxpd) && "合格".equals(jtylStrDxpd) &&
                                        "合格".equals(bjyaStrDxpd) && "合格".equals(bjsqStrDxpd) && "合格".equals(hxzl50_dxpd) && "合格".equals(hxzl100_dxpd)) {
                                    reportNew.reportStatue = 1; //合格
                                } else {
                                    reportNew.reportStatue = 2; //不合格
                                }
                            }
                            //报告的进展  待核验
                            reportNew.reportProgress = 1;
                            //子类状态先设置为0
                            reportNew.failedStart = 0;
                            reportNew.bsbhHrader = sample.bsbhHrader;
                            reportNew.erweima = sample.erweima;
                            reportNew.wtfId = sample.respirator.wtfId;
                            reportNew.wtf = sample.respirator.wtf;

                            reportNew.wtfIdChi = sample.wtfIdChi;
                            reportNew.wtfChi = sample.wtfChi;

                            reportNew.sjr = sample.sjr;
                            reportNew.zzcsId = sample.zzcsId;
                            reportNew.zzcs = sample.zzcs;

                            reportNew.zfzddhy = 0;
                            reportNew.jyyId = sample.respirator.jcrId;

                            RespiratorReport respiratorReport = new RespiratorReport();
                            respiratorReport.bh = sample.bh;
                            respiratorReport.wtfId = sample.respirator.wtfId;
                            respiratorReport.wtf = sample.respirator.wtf;
                            respiratorReport.sjrId = sample.respirator.sjrId;
                            respiratorReport.sjr = sample.respirator.sjr;
                            respiratorReport.ypmc = "正压式空气呼吸器";
                            respiratorReport.zzcsId = sample.respirator.zzcsId;
                            respiratorReport.zzcs = sample.respirator.zzcs;
                            respiratorReport.xhgg = sample.respirator.xhgg;
                            respiratorReport.ccbh = sample.respirator.ccbh;
                            if (reportNew.reportStatue == 2) {
                                respiratorReport.jyjl = "不合格";
                            }
                            //如果没有代表批量 或者为空
                            if(null ==sample.respirator.dbpl || "".equals(sample.respirator.dbpl)){
                                respiratorReport.dbpl="";
                            }else{
                                respiratorReport.dbpl=sample.respirator.dbpl;
                            }
                            respiratorReport.fzdw = "";
                            respiratorReport.pzrId = "";
                            respiratorReport.pzr = "";
                            respiratorReport.hyyId = "";
                            respiratorReport.hyy = "";

                            respiratorReport.jyyId = sample.respirator.jcrId;
                            respiratorReport.jyy = sample.respirator.jcr;


                            if(mOtherInput==null){
                                respiratorReport.jydwsqh = mOtherInput.mz_jydwsqh;
                            }else{
                                respiratorReport.jydwsqh =Config.MZ_JTDWSQH;
                            }

                            //计算有效期
                            // 有效日期是送检日期 的下一年的前一天
                            long year1 = TimeUtil.getDateBeforeYear(datem2, 1);
                            reportNew.jyrqNian = TimeUtil.formatTime_Year(datem2.getTime());
                            reportNew.jyrqYue = TimeUtil.formatTime_Month(datem2.getTime());
                            respiratorReport.yxrq = TimeUtil.formatTime_tow(year1);
                            respiratorReport.jyrq = TimeUtil.formatTime_tow(datem2.getTime());
                            respiratorReport.sjrq = sample.respirator.sjri;
                            reportNew.xcjyrq = year1;
                            reportNew.setAddTime(TimeUtil.currentTimeMillis());
                            //设置匹配气瓶的信息
                            respiratorReport.qpbsh = sample.respirator.qpbsh;
                            respiratorReport.nr_ypmc = "正压式空气呼吸器";
                            respiratorReport.nr_syrId = "";
                            respiratorReport.nr_syr = sample.respirator.sjr;
                            respiratorReport.nr_ypsl = 1;
                            respiratorReport.nr_ypztms = "完好";
                            respiratorReport.nr_sb = sample.respirator.sbstr;
//                            if(sample.respirator.sfxp == 1){
//                                respiratorReport.nr_ypdj = "新品";
//                            }else{
//                                respiratorReport.nr_ypdj = "旧品";
//                            }
                            if(sample.respirator.xjpType ==0 ||sample.respirator.xjpType ==1){
                                respiratorReport.nr_ypdj = "旧品";
                            }else{
                                respiratorReport.nr_ypdj = "新品";
                            }
                            //如果是抽检
                            if(sample.spType ==1){
                                respiratorReport.nr_jylx = "委托检验";
                            }else{
                                respiratorReport.nr_jylx = "质量抽检";
                            }
                            respiratorReport.nr_scrq = sample.respirator.scrq;
                            respiratorReport.nr_dyrq = sample.respirator.sjri;
                            respiratorReport.nr_ybhph = sample.sbbh;

                            String qunm = sample.bsbh;
                            String[] qnmmm = qunm.split("DQFJ");
                            respiratorReport.nr_ypjsbh = qnmmm[1];

                            respiratorReport.nr_jyxm = "5项";
                            respiratorReport.nr_jyyj = "AQ/T6110-2012《工业空气呼吸器安全使用维护管理规范》";
                            respiratorReport.nr_jyjl = "依据标准AQ/T6110-2012《工业空气呼吸器安全使用维护管理规范》检查，该样品索检项目符合要求。声明：本中心承诺检验检测方法有效，并对检测结果负责";
                            respiratorReport.nr_jfrq = "";
                            respiratorReport.nr_jybgzyz = "";
                            respiratorReport.nr_bz = "";

                            respiratorReport.nr_wg_jszb = "符合AQ/T6110-2012表 定期技术检测外观检查表要求";
                            respiratorReport.nr_wg_jyjg = "";
                            respiratorReport.nr_wg_dxpd = "";

                            respiratorReport.nr_mz_jszb = "面罩泄漏测试小于-25Pa";
                            respiratorReport.nr_mz_jyjg = mzxlceStrJyjg;
                            respiratorReport.nr_mz_dxpd = mzxlceStrDxpd;


                            respiratorReport.nr_ylb_jszb = "压力表1min内下降不大于2MPa";
                            if("/".equals(zjqmxStrJyjg)){
                                respiratorReport.nr_ylb_jyjg = "";
                            }else{
                                respiratorReport.nr_ylb_jyjg = zjqmxStrJyjg;
                            }

                            respiratorReport.nr_ylb_dxpd = zjqmxStrDxpd;


                            respiratorReport.nr_jtyl_jszb = "（0~500）Pa并小于呼吸阀开启压力";
                            respiratorReport.nr_jtyl_jyjg = jtylStrJyjg;
                            respiratorReport.nr_jtyl_dxpd = jtylStrDxpd;


                            respiratorReport.nr_bjyl_jszb = "（5.5±0.5）MPa";
                            respiratorReport.nr_bjyl_jyjg = bjyaStrJyjg;
                            respiratorReport.nr_bjyl_dxpd = bjyaStrDxpd;

                            respiratorReport.nr_bjsq_jszb = "不小于90dB(A)";
                            respiratorReport.nr_bjsq_jyjg = bjsqStrJyjg + "dB(A)";
                            respiratorReport.nr_bjsq_dxpd = bjsqStrDxpd;
                            //100L/min
                            respiratorReport.nr_hxzl_mc1 = "气瓶额定压力至2MPa呼吸器频率40次/min呼吸流量100L/min";
                            respiratorReport.nr_hxzl_jszb1 = "吸气阻力不大于500Ma 呼气阻力不大于1000Pa";
                            respiratorReport.nr_hxzl_jyjg1_x = "吸气阻力：" + hxzl100_x + "Pa";
                            respiratorReport.nr_hxzl_jyjg1_d = "呼气阻力：" + hxzl100_d + "Pa";
                            respiratorReport.nr_hxzl_dxpd1 = hxzl100_dxpd;
                            //50L/min
                            respiratorReport.nr_hxzl_mc2 = "气瓶额定压力至2MPa至1MPa呼吸器频率40次/min呼吸流量100L/min";
                            respiratorReport.nr_hxzl_jszb2 = "吸气阻力不大于500Ma 呼气阻力不大于700Pa";
                            respiratorReport.nr_hxzl_jyjg2_x = "吸气阻力：" + hxzl50_x + "Pa";
                            respiratorReport.nr_hxzl_jyjg2_d = "呼气阻力：" + hxzl50_d + "Pa";
                            respiratorReport.nr_hxzl_dxpd2 = hxzl50_dxpd;
                            Date date = khxinBean.headers.getDatetime();
                            //报告的测试日期
                            respiratorReport.bgCsrq = date.getTime();

                            HltHxqbean hltHxqbean = new HltHxqbean();
                            if(null !=khxinBean.headers && null !=khxinBean.headers.getDatetime()){
                                //测试日期
                                hltHxqbean.hlt_csrq =TimeUtil.formatTime_three(khxinBean.headers.getDatetime().getTime());
                            }
                            //使用单位
                            hltHxqbean. hlt_sydw = sample.respirator.wtf;
                            //制造厂商
                            hltHxqbean.hlt_zzcs = sample.respirator.zzcs;
                            //产品信号
                            hltHxqbean.hlt_cpxh = sample.respirator.xhgg;
                            //产品编号
                            hltHxqbean.hlt_cpbh = sample.bsbh;
                            //整机气密性
                            hltHxqbean.hlt_zjqmx =zjqmxStrDxpd+" "+zjqmxStrJyjg;
                            //面罩泄露测试
                            hltHxqbean.hlt_mzxlcs =mzxlceStrDxpd+ " "+mzxlceStrJyjg_hlt;
                            //开启/静压测试
                            hltHxqbean.hlt_kqjycs = jtylStrDxpd+ "" +jtylStrJyjg;
                            //报警压力测试
                            hltHxqbean.hlt_bjylcs = bjyaStrDxpd+ " "+bjyaStrJyjg;

                            if(null != khxinBean.gaugetests){
                                Gaugetests gaug =  khxinBean.gaugetests;
                                //压力表校验  合格：不合格
                                hltHxqbean.hlt_ylbjy_str = gaug.getResult() ==1?"合格":"不合格";
                                //实测值1
                                hltHxqbean.hlt_ylz_sc1 = "10 Mpa";
                                //实测值2
                                hltHxqbean.hlt_ylz_sc2 = "15 Mpa";
                                //实测值3
                                hltHxqbean.hlt_ylz_sc3 = "20 Mpa";

                                DecimalFormat df   =new   java.text.DecimalFormat("#.0");
                                df.setRoundingMode(RoundingMode.FLOOR);//不四舍五入


                                double hlt_ylz_d11 = ((double)gaug.getPr3()/10);
                                double hlt_ylz_d22 = ((double)gaug.getPr2()/10);
                                double hlt_ylz_d33 = ((double)gaug.getPr1()/10);

                                if(hlt_ylz_d11== 0){
                                    //表压值1
                                    hltHxqbean.hlt_ylz_by1 = "";
                                }else{
                                    //表压值1
                                    hltHxqbean.hlt_ylz_by1 = df.format(hlt_ylz_d11)+"Mpa";
                                }

                                if(hlt_ylz_d22== 0){
                                    //表压值2
                                    hltHxqbean.hlt_ylz_by2 = "";
                                }else{
                                    //表压值2
                                    hltHxqbean.hlt_ylz_by2 = df.format(hlt_ylz_d22)+"Mpa";
                                }

                                if(hlt_ylz_d33 == 0){
                                    //表压值3
                                    hltHxqbean.hlt_ylz_by3 = "";
                                }else{
                                    //表压值3
                                    hltHxqbean.hlt_ylz_by3 = df.format(hlt_ylz_d33)+"Mpa";
                                }

                                //呼吸阻力50L/min
                                hltHxqbean.hlt_zl50_x =hxzl50_x;
                                hltHxqbean.hlt_zl50_d=  hxzl50_d;
                                hltHxqbean.hlt_zl50_jg = hxzl50_dxpd;
                                //呼吸阻力100L/min
                                hltHxqbean.hlt_zl100_x = hxzl100_x;
                                hltHxqbean.hlt_zl100_d = hxzl100_d;
                                hltHxqbean.hlt_zl100_jg = hxzl100_dxpd;
                            }
                            if(null != khxinBean.visualtests){
                                Visualtests vv=  khxinBean.visualtests;
                                if(vv.getFacepiece() == 1){
                                    hltHxqbean.ms_mz ="合格";
                                }else if(vv.getFacepiece() == 2){
                                    hltHxqbean.ms_mz ="不合格";
                                }else{
                                    hltHxqbean.ms_mz ="";
                                }


                                if(vv.getCarrier() == 1){
                                    hltHxqbean.ms_bjsd ="合格";
                                } else if(vv.getCarrier() == 2){
                                    hltHxqbean.ms_bjsd ="不合格";
                                }else{
                                    hltHxqbean.ms_bjsd ="";
                                }

                                if(vv.getCylinder() == 1){
                                    hltHxqbean.ms_qp ="合格";
                                } else if(vv.getCylinder() == 2){
                                    hltHxqbean.ms_qp ="不合格";
                                }else{
                                    hltHxqbean.ms_qp ="";
                                }

                                if(vv.getWarning() == 1){
                                    hltHxqbean.ms_dyljg ="合格";
                                } else if(vv.getWarning() == 2){
                                    hltHxqbean.ms_dyljg ="不合格";
                                }else{
                                    hltHxqbean.ms_dyljg ="";
                                }
                                if(vv.getHoses() == 1){
                                    hltHxqbean.ms_jg ="合格";
                                } else if(vv.getHoses() == 2){
                                    hltHxqbean.ms_jg ="不合格";
                                }else{
                                    hltHxqbean.ms_jg ="";
                                }

                            }
                            if(null !=khxinBean.headers){
                                //测试人员
                                String hlt_csry =khxinBean.headers.getUsername();
                                hltHxqbean.hlt_csry = hlt_csry;
                            }
                            respiratorReport.khxinBean= hltHxqbean;
                            reportNew.respirator = respiratorReport;
                            reportDao.save(reportNew);
                        }
                    }


                    //------------------------------生成面罩的报告end ------------------------------------
                }



                // -------------------------------------------------------------------压力表Start-------------------
                //先 查询这条数据有没有生成 呼吸器的报告
                Report reportOldYlb = reportDao.getReportBybsbhAdType(sample.bsbh, 3);
                if (null != reportOldYlb && reportOldYlb.sbbh.equals(sernums.getSernum())) {
                    Date date = khxinBean.headers.getDatetime();
                    if(date.getTime()> reportOldYlb.respirator.bgCsrq){
                        reportOldYlb.bh = sample.bh + "_ylb";
                        //标识编号
                        reportOldYlb.bsbh = sample.bsbh;
                        //设备编号
                        reportOldYlb.sbbh = sernums.getSernum();
                        //样品类型
                        reportOldYlb.type = reportOldYlb.BG_TYPE_YLB;
                        reportOldYlb.spType = sample.spType;
                        //任务单编号
                        reportOldYlb.rwdbh = sample.rwdbh;
                        //接收日期时间戳
                        reportOldYlb.jsrqLong = sample.jsrqLong;
                        reportOldYlb.pxzd = sample.pxzd;
                        String sczStr_b_1="";
                        String sczStr_b_2="";
                        String sczStr_b_3="";

                        String byzStr_b_1="";
                        String byzStr_b_2="";
                        String byzStr_b_3="";

                        DecimalFormat df   =new   java.text.DecimalFormat("#.0");
                        df.setRoundingMode(RoundingMode.FLOOR);//不四舍五入

                        PressureReport pressureReport = new PressureReport();
                        if(null != khxinBean.gaugetests){
                            Gaugetests gaug =  khxinBean.gaugetests;

                            double hlt_ylz_d11 = 0;
                            double hlt_ylz_d22 = 0;
                            double hlt_ylz_d33 = 0;

                            if(null != gaug.getPr3()){
                                double aai1  = ((double)gaug.getPr1()/10);
                                hlt_ylz_d11 = Double.parseDouble(df.format(aai1));
                            }

                            if(gaug.getPr2() !=null){
                                double aai2  = ((double)gaug.getPr2()/10);
                                hlt_ylz_d22 = Double.parseDouble(df.format(aai2));
                            }
                            if(null !=gaug.getPr1()){
                                double aai3  = ((double)gaug.getPr3()/10);
                                hlt_ylz_d33 = Double.parseDouble(df.format(aai3));
                            }

                            if(hlt_ylz_d11 != 0 && hlt_ylz_d22 != 0 && hlt_ylz_d33 !=0){
                                //压力表校验  合格：不合格
                                if(gaug.getResult() ==1){
                                    reportOldYlb.reportStatue = 1; //合格
                                    pressureReport.jl = "本次压力表校验合格。";
                                }else{
                                    reportOldYlb.reportStatue = 2; //不合格
                                    pressureReport.jl = "本次压力表校验不合格。";//子类状态先设置为0
                                    reportOldYlb.failedStart = 0;
                                }
                            }else{
                                reportOldYlb.reportStatue = 2; //不合格
                                pressureReport.jl = "本次压力表校验不合格。";//子类状态先设置为0
                                reportOldYlb.failedStart = 0;

                            }
                            sczStr_b_1="";
                            sczStr_b_2="";
                            sczStr_b_3="";

                            DecimalFormat df2   =new   java.text.DecimalFormat("#.0");
                            df2.setRoundingMode(RoundingMode.FLOOR);//不四舍五入
                            //
                            if(null == gaug.getPt1() || "".equals(gaug.getPt1())){
                                sczStr_b_1 ="";
                            }else{
                                String [] mmm1 = gaug.getPt1().split("bar");
                                if(mmm1.length>0){
                                    double mmm22 = Double.parseDouble(mmm1[0]);
                                    double  m3m3m3 =mmm22/10;
                                    sczStr_b_1 = df2.format(m3m3m3)+" MPa";
                                }
                            }


                            if(null == gaug.getPt2() || "".equals(gaug.getPt2())){
                                sczStr_b_2="";
                            }else{
                                String [] mmm1 = gaug.getPt2().split("bar");
                                if(mmm1.length>0){
                                    double mmm22 = Double.parseDouble(mmm1[0]);
                                    double  m3m3m3 =mmm22/10;
                                    sczStr_b_2 = df2.format(m3m3m3)+" MPa";
                                }
                            }

                            if(null == gaug.getPt2() || "".equals(gaug.getPt2())){
                                sczStr_b_3="";
                            }else{
                                String [] mmm1 = gaug.getPt3().split("bar");
                                if(mmm1.length>0){
                                    double mmm22 = Double.parseDouble(mmm1[0]);
                                    double  m3m3m3 =mmm22/10;
                                    sczStr_b_3 = df2.format(m3m3m3)+" MPa";
                                }
                            }
                            if(hlt_ylz_d11 != 0){
                                byzStr_b_1 = hlt_ylz_d11+" MPa";
                            }else{
                                byzStr_b_1="";
                            }

                            if(hlt_ylz_d22 != 0){
                                byzStr_b_2 = hlt_ylz_d22+" MPa";
                            }else{
                                byzStr_b_2 ="";
                            }

                            if(hlt_ylz_d33 != 0){
                                byzStr_b_3 = hlt_ylz_d33+" MPa";
                            }else {
                                byzStr_b_3="";
                            }
                        }else{
                            reportOldYlb.reportStatue = 2; //不合格
                            pressureReport.jl = "本次压力表未进行校验。";
                            //子类状态先设置为0
                            reportOldYlb.failedStart = 1;

                            sczStr_b_1="";
                            sczStr_b_2="";
                            sczStr_b_3="";

                            byzStr_b_1="";
                            byzStr_b_2="";
                            byzStr_b_3="";

                        }
                        //报告的进展  待核验
                        reportOldYlb.reportProgress = 1;
                        reportOldYlb.bsbhHrader = sample.bsbhHrader;
                        reportOldYlb.erweima = sample.erweima;
                        reportOldYlb.wtfId = sample.respirator.wtfId;
                        reportOldYlb.wtf = sample.respirator.wtf;

                        reportOldYlb.wtfIdChi = sample.wtfIdChi;
                        reportOldYlb.wtfChi = sample.wtfChi;

                        reportOldYlb.sjr = sample.sjr;
                        reportOldYlb.zzcsId = sample.zzcsId;
                        reportOldYlb.zzcs = sample.zzcs;

                        reportOldYlb.jyrqNian = TimeUtil.formatTime_Year(date.getTime());
                        reportOldYlb.jyrqYue = TimeUtil.formatTime_Month(date.getTime());
                        reportOldYlb.zfzddhy = 0;
                        reportOldYlb.jyyId = sample.respirator.jcrId;


                        long year1 = TimeUtil.getDateBeforeYear(TimeUtil.parsex(sample.respirator.sjri), 1);
                        reportOldYlb.xcjyrq = year1;
                        reportOldYlb.setAddTime(TimeUtil.currentTimeMillis());


                        if ("".equals(byzStr_b_1)) {
                            pressureReport.byz1 = "/";
                        } else {
                            pressureReport.byz1 = byzStr_b_1;
                        }

                        if ("".equals(byzStr_b_2)) {
                            pressureReport.byz2 = "/";
                        } else {
                            pressureReport.byz2 = byzStr_b_2;
                        }

                        if ("".equals(byzStr_b_3)) {
                            pressureReport.byz3 = "/";
                        } else {
                            pressureReport.byz3 = byzStr_b_3;
                        }




                        if("".equals(sczStr_b_1)){
                            pressureReport.scz1 = "/";
                        }else{
                            pressureReport.scz1 =sczStr_b_1;
                        }

                        if("".equals(sczStr_b_2)){
                            pressureReport.scz2 = "/";
                        }else{
                            pressureReport.scz2 =sczStr_b_2;
                        }


                        if("".equals(sczStr_b_3)){
                            pressureReport.scz3 = "/";
                        }else{
                            pressureReport.scz3 = sczStr_b_3;
                        }



                        //--------------红蓝图start
                        HltHxqbean hltHxqbean = new HltHxqbean();

                        //面罩泄露测试小于-25Pa 检验结果
                        String mzxlceStrJyjg = "";
                        String mzxlceStrJyjg_hlt="";
                        //面罩泄露测试小于-25Pa 单项判定
                        String mzxlceStrDxpd = "";

                        //压力表1min 内的下降不大于2Mpa 检验结果
                        String zjqmxStrJyjg = "";
                        //压力表1min 内的下降不大于2Mpa 单项判刑
                        String zjqmxStrDxpd = "";

                        //静态压力 检验结果
                        String jtylStrJyjg = "";
                        //静态压力 单项判定
                        String jtylStrDxpd = "";

                        //报警压力 检验结果
                        String bjyaStrJyjg = "";
                        //报警压力 单项判定
                        String bjyaStrDxpd = "";

                        //报警声强 检验结果
                        String bjsqStrJyjg = "";
                        //报警声强 单项判定
                        String bjsqStrDxpd = "";

                        //压力试验类
                        List<Pressuretests> pressuretestsList = khxinBean.pressuretests;
                        for (Pressuretests pressuretests : pressuretestsList) {
                            if (null != pressuretests.getTesttype()) {
                                switch (pressuretests.getTesttype()) {
                                    case 1:  //面具泄露
                                        if(pressuretests.getPress() != null){
                                            if((pressuretests.getPress()*10)>0){
                                                mzxlceStrJyjg_hlt = "-" + (pressuretests.getPress() * 100 + "Pa");
                                            }else{
                                                mzxlceStrJyjg_hlt = (pressuretests.getPress()* 100 + "Pa");
                                            }
                                            mzxlceStrJyjg ="见附页";
                                        }else{
                                            mzxlceStrJyjg ="";
                                        }

                                        if (pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            mzxlceStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            mzxlceStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            mzxlceStrDxpd = "不合格";
                                        }
                                        break;
                                    case 2:  //中压更改
                                        break;
                                    case 3: //中压更改
                                        break;
                                    case 4: //高压力泄露   ---整机气密性
                                        if(null == pressuretests.getPress()){
                                            zjqmxStrJyjg="";
                                        }else{
                                            zjqmxStrJyjg = pressuretests.getPress() / 10 + "";
                                        }
                                        if (null == pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            zjqmxStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            zjqmxStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            zjqmxStrDxpd = "不合格";
                                        }
                                        break;
                                    case 6: //静态面具压力
                                        if(null  == pressuretests.getPress()){
                                            jtylStrJyjg = "";
                                        }else{
                                            float nfnf = pressuretests.getPress() ;
                                            int dede = (int) (nfnf *100) ;
                                            jtylStrJyjg = dede + "Pa";
                                        }
                                        if (null ==pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            jtylStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            jtylStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            jtylStrDxpd = "不合格";
                                        }

                                        break;

                                    case 14: //报警哨
                                        //
                                        if(null == pressuretests.getPress()){
                                            bjyaStrJyjg="";
                                        }else{

                                            DecimalFormat df3   =new   java.text.DecimalFormat("#.00");
                                            df3.setRoundingMode(RoundingMode.FLOOR);//不四舍五入
                                            double xxx1 = pressuretests.getPress() / 10;
                                            String xxx2= df3.format(xxx1);
                                            bjyaStrJyjg = xxx2 + "MPa";
                                        }
                                        if (null ==pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            bjyaStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            bjyaStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            bjyaStrDxpd = "不合格";
                                        }
                                        break;
                                    case 15: // 振铃
                                        break;

                                }
                            }
                        }

                        //呼吸阻力100L/min  单项判定
                        String hxzl100_dxpd = "";
                        //呼吸阻力100L/min 最小值
                        String hxzl100_x = "";
                        //呼吸阻力100L/min  最大值
                        String hxzl100_d = "";
                        byte[] hxzl100_img;

                        //呼吸阻力50L/min  单项判定
                        String hxzl50_dxpd = "";
                        //呼吸阻力100L/min 最小值
                        String hxzl50_x = "";
                        //呼吸阻力100L/min  最大值
                        String hxzl50_d = "";

                        byte[] hxzl150_img;


                        List<Breathingtests> breathingtests = khxinBean.breathingtests;
                        for (Breathingtests breathingtests1 : breathingtests) {
                            if (breathingtests1.getTesttype() == 9) {
                                if (breathingtests1.getTestorder() == 1) { //呼吸阻力 50L/min
                                    if (breathingtests1.getResult() == 1) { //合格
                                        hxzl50_dxpd = "合格";
                                    } else {  //不合格
                                        hxzl50_dxpd = "不合格";
                                    }
                                    if(null ==breathingtests1.getBmin()){
                                        hxzl50_x="";
                                    }else{
                                        hxzl50_x = ((int)(breathingtests1.getBmin() * 100)) + "";
                                    }

                                    if(null == breathingtests1.getBmax()){
                                        hxzl50_d = "";
                                    }else{
                                        hxzl50_d = ((int)(breathingtests1.getBmax() * 100)) + "";
                                    }
                                    //图片
                                    hxzl150_img = breathingtests1.getGraph();
                                    //if(null != hxzl150_img){
                                    //    boolean isok =  saveImageToLoacl(hxzl150_img,sample.bsbh+"_m50.png");
                                    //    if(isok){
                                    //        reportOldYlb.hltImg1 = "/up/fxq/"+sample.bsbh+"_m50.png";
                                    //    }else{
                                    //        reportOldYlb.hltImg1 ="";
                                    //    }
                                    //}else{
                                    //    reportOldYlb.hltImg1 ="";
                                    //}

                                    if(null != hxzl150_img){
                                        String  zhstr = saveImageToLoacl150(hxzl150_img,sample);
                                        reportOldYlb.hltImg1 = zhstr;
                                    }else{
                                        reportOldYlb.hltImg1 ="";
                                    }

                                } else if (breathingtests1.getTestorder() == 2) {//呼吸阻力 100L/min
                                    if (breathingtests1.getResult() == 1) { //合格
                                        hxzl100_dxpd = "合格";
                                    } else {  //不合格
                                        hxzl100_dxpd = "不合格";
                                    }
                                    if(null ==breathingtests1.getBmin()){
                                        hxzl100_x = "";
                                    }else{
                                        hxzl100_x = ((int)(breathingtests1.getBmin() * 100)) + "";
                                    }

                                    if(null ==breathingtests1.getBmax()){
                                        hxzl100_d ="";
                                    }else{
                                        hxzl100_d = ((int)(breathingtests1.getBmax() * 100)) + "";
                                    }
                                    hxzl100_img = breathingtests1.getGraph();
                                    //if(null != hxzl100_img){
                                    //    boolean isok =  saveImageToLoacl(hxzl100_img,sample.bsbh+"_m100.png");
                                    //    if(isok){
                                    //        reportOldYlb.hltImg2 ="/up/fxq/"+sample.bsbh+"_m100.png";
                                    //    }else{
                                    //        reportOldYlb.hltImg2 ="";
                                    //    }
                                    //}else{
                                    //    reportOldYlb.hltImg2 ="";
                                    //}

                                    if(null != hxzl100_img){
                                        String zhstr100 = saveImageToLoacl100(hxzl100_img,sample);
                                        reportOldYlb.hltImg2 = zhstr100;
                                    }else{
                                        reportOldYlb.hltImg2 ="";
                                    }
                                }
                            }
                        }




                        if(null !=khxinBean.headers && null !=khxinBean.headers.getDatetime()){
                            //测试日期
                            hltHxqbean.hlt_csrq =TimeUtil.formatTime_three(khxinBean.headers.getDatetime().getTime());
                        }
                        //使用单位
                        hltHxqbean. hlt_sydw = sample.respirator.wtf;
                        //制造厂商
                        hltHxqbean.hlt_zzcs = sample.respirator.zzcs;
                        //产品信号
                        hltHxqbean.hlt_cpxh = sample.respirator.xhgg;
                        //产品编号
                        hltHxqbean.hlt_cpbh = sample.bsbh;
                        //整机气密性
                        hltHxqbean.hlt_zjqmx =zjqmxStrDxpd+"    "+zjqmxStrJyjg;


                        //面罩泄露测试
                        hltHxqbean.hlt_mzxlcs =mzxlceStrDxpd+ "  "+mzxlceStrJyjg_hlt;
                        //开启/静压测试
                        hltHxqbean.hlt_kqjycs = jtylStrDxpd+ "   " +jtylStrJyjg;
                        //报警压力测试
                        hltHxqbean.hlt_bjylcs = bjyaStrDxpd+ "   "+bjyaStrJyjg;
                        if(null != khxinBean.gaugetests){
                            Gaugetests gaug =  khxinBean.gaugetests;
                            //压力表校验  合格：不合格
                            hltHxqbean.hlt_ylbjy_str = gaug.getResult() ==1?"合格":"不合格";
                            //实测值1
                            hltHxqbean.hlt_ylz_sc1 = "10 Mpa";
                            //实测值2
                            hltHxqbean.hlt_ylz_sc2 = "15 Mpa";
                            //实测值3
                            hltHxqbean.hlt_ylz_sc3 = "20 Mpa";




                            double hlt_ylz_d11 = ((double)gaug.getPr3()/10);
                            double hlt_ylz_d22 = ((double)gaug.getPr2()/10);
                            double hlt_ylz_d33 = ((double)gaug.getPr1()/10);

                            if(hlt_ylz_d11== 0){
                                //表压值1
                                hltHxqbean.hlt_ylz_by1 = "";
                            }else{
                                //表压值1
                                hltHxqbean.hlt_ylz_by1 = df.format(hlt_ylz_d11)+"Mpa";
                            }

                            if(hlt_ylz_d22== 0){
                                //表压值2
                                hltHxqbean.hlt_ylz_by2 = "";
                            }else{
                                //表压值2
                                hltHxqbean.hlt_ylz_by2 = df.format(hlt_ylz_d22)+"Mpa";
                            }

                            if(hlt_ylz_d33 == 0){
                                //表压值3
                                hltHxqbean.hlt_ylz_by3 = "";
                            }else{
                                //表压值3
                                hltHxqbean.hlt_ylz_by3 = df.format(hlt_ylz_d33)+"Mpa";
                            }

                            //呼吸阻力50L/min
                            hltHxqbean.hlt_zl50_x =hxzl50_x;
                            hltHxqbean.hlt_zl50_d=  hxzl50_d;
                            hltHxqbean.hlt_zl50_jg = hxzl50_dxpd;
                            //呼吸阻力100L/min
                            hltHxqbean.hlt_zl100_x = hxzl100_x;
                            hltHxqbean.hlt_zl100_d = hxzl100_d;
                            hltHxqbean.hlt_zl100_jg = hxzl100_dxpd;
                        }

                        if(null != khxinBean.visualtests){
                            Visualtests vv=  khxinBean.visualtests;
                            if(vv.getFacepiece() == 1){
                                hltHxqbean.ms_mz ="合格";
                            }else if(vv.getFacepiece() == 2){
                                hltHxqbean.ms_mz ="不合格";
                            }else{
                                hltHxqbean.ms_mz ="";
                            }


                            if(vv.getCarrier() == 1){
                                hltHxqbean.ms_bjsd ="合格";
                            } else if(vv.getCarrier() == 2){
                                hltHxqbean.ms_bjsd ="不合格";
                            }else{
                                hltHxqbean.ms_bjsd ="";
                            }

                            if(vv.getCylinder() == 1){
                                hltHxqbean.ms_qp ="合格";
                            } else if(vv.getCylinder() == 2){
                                hltHxqbean.ms_qp ="不合格";
                            }else{
                                hltHxqbean.ms_qp ="";
                            }

                            if(vv.getWarning() == 1){
                                hltHxqbean.ms_dyljg ="合格";
                            } else if(vv.getWarning() == 2){
                                hltHxqbean.ms_dyljg ="不合格";
                            }else{
                                hltHxqbean.ms_dyljg ="";
                            }
                            if(vv.getHoses() == 1){
                                hltHxqbean.ms_jg ="合格";
                            } else if(vv.getHoses() == 2){
                                hltHxqbean.ms_jg ="不合格";
                            }else{
                                hltHxqbean.ms_jg ="";
                            }

                        }

                        if(null !=khxinBean.headers){
                            //测试人员
                            String hlt_csry =khxinBean.headers.getUsername();
                            hltHxqbean.hlt_csry = hlt_csry;
                        }
                        pressureReport.khxinBean= hltHxqbean;
                        //--------------红蓝图end


                        if(null!=mOtherInput){
                            //检验单位授权号
                            pressureReport.jydwsqh = mOtherInput.ylb_jydwsqh;
                        }else{
                            //检验单位授权号
                            pressureReport.jydwsqh = Config.YLB_JTDWSQH;
                        }

                        pressureReport.jyyId = sample.respirator.jcrId;
                        pressureReport.jyy = sample.respirator.jcr;
                        pressureReport.jyrq = sample.respirator.sjri;
                        //获取测试日期 2020/1/3 15:03:02
                        Date bgcerqStr =khxinBean.headers.getDatetime();
                        //报告的测试日期
                        pressureReport.bgCsrq = bgcerqStr.getTime();
                        reportOldYlb.pressure = pressureReport;
                        reportDao.save(reportOldYlb);
                    }
                }else{

                    Date datem2 = khxinBean.headers.getDatetime();
                    //如果送检日期的时间戳 减去 实验数据上面的时间戳  两者相差超过20天  就不用生成报告
                    int chazhi = TimeUtil.getOffectDay(sample.jsrqLong,datem2.getTime());
                    int difference = Math.abs(chazhi);
                    //如果差值小于20天 就生成数据
                    if(difference< Config.SJSC_DAY){
                        Report report = new Report();
                        report.bh = sample.bh + "_ylb";
                        //标识编号
                        report.bsbh = sample.bsbh;
                        //设备编号
                        report.sbbh = sernums.getSernum();
                        //样品类型
                        report.type = report.BG_TYPE_YLB;
                        report.spType = sample.spType;
                        //接收日期时间戳
                        report.jsrqLong = sample.jsrqLong;
                        report.pxzd = sample.pxzd;
                        //任务单编号
                        report.rwdbh = sample.rwdbh;

                        String sczStr_b_1="";
                        String sczStr_b_2="";
                        String sczStr_b_3="";

                        String byzStr_b_1="";
                        String byzStr_b_2="";
                        String byzStr_b_3="";

                        DecimalFormat df   =new   java.text.DecimalFormat("#.0");
                        df.setRoundingMode(RoundingMode.HALF_UP);//不四舍五入

                        PressureReport pressureReport = new PressureReport();
                        if(null != khxinBean.gaugetests){
                            Gaugetests gaug =  khxinBean.gaugetests;

                            double hlt_ylz_d11 = 0;
                            double hlt_ylz_d22 = 0;
                            double hlt_ylz_d33 = 0;

                            if(null != gaug.getPr3()){
                                double aai1  = ((double)gaug.getPr1()/10);
                                hlt_ylz_d11 = Double.parseDouble(df.format(aai1));
                            }

                            if(gaug.getPr2() !=null){
                                double aai2  = ((double)gaug.getPr2()/10);
                                hlt_ylz_d22 = Double.parseDouble(df.format(aai2));
                            }
                            if(null !=gaug.getPr1()){
                                double aai3  = ((double)gaug.getPr3()/10);
                                hlt_ylz_d33 = Double.parseDouble(df.format(aai3));
                            }

                            if(hlt_ylz_d11 != 0 && hlt_ylz_d22 != 0 && hlt_ylz_d33 !=0){
                                //压力表校验  合格：不合格
                                if(gaug.getResult() ==1){
                                    report.reportStatue = 1; //合格
                                    pressureReport.jl = "本次压力表校验合格。";//子类状态先设置为0
                                }else{
                                    report.reportStatue = 2; //不合格
                                    pressureReport.jl = "本次压力表校验不合格。";//子类状态先设置为0
                                    report.failedStart = 0;
                                }
                            }else{
                                report.reportStatue = 2; //不合格
                                pressureReport.jl = "本次压力表校验不合格。";//子类状态先设置为0
                                report.failedStart = 0;
                            }
                            sczStr_b_1="";
                            sczStr_b_2="";
                            sczStr_b_3="";

                            DecimalFormat df2   =new   java.text.DecimalFormat("#.0");
                            df2.setRoundingMode(RoundingMode.HALF_UP);//不四舍五入
                            //
                            if(null == gaug.getPt1() || "".equals(gaug.getPt1())){
                                sczStr_b_1 ="";
                            }else{
                                String [] mmm1 = gaug.getPt1().split("bar");
                                if(mmm1.length>0){
                                    double mmm22 = Double.parseDouble(mmm1[0]);
                                    double  m3m3m3 =mmm22/10;
                                    sczStr_b_1 = df2.format(m3m3m3)+" MPa";
                                }
                            }


                            if(null == gaug.getPt2() || "".equals(gaug.getPt2())){
                                sczStr_b_2="";
                            }else{
                                String [] mmm1 = gaug.getPt2().split("bar");
                                if(mmm1.length>0){
                                    double mmm22 = Double.parseDouble(mmm1[0]);
                                    double  m3m3m3 =mmm22/10;
                                    sczStr_b_2 = df2.format(m3m3m3)+" MPa";
                                }
                            }

                            if(null == gaug.getPt2() || "".equals(gaug.getPt2())){
                                sczStr_b_3="";
                            }else{
                                String [] mmm1 = gaug.getPt3().split("bar");
                                if(mmm1.length>0){
                                    double mmm22 = Double.parseDouble(mmm1[0]);
                                    double  m3m3m3 =mmm22/10;
                                    sczStr_b_3 = df2.format(m3m3m3)+" MPa";
                                }
                            }


                            if(hlt_ylz_d11 != 0){
                                byzStr_b_1 = hlt_ylz_d11+" MPa";
                            }else{
                                byzStr_b_1="";
                            }

                            if(hlt_ylz_d22 != 0){
                                byzStr_b_2 = hlt_ylz_d22+" MPa";
                            }else{
                                byzStr_b_2 ="";
                            }

                            if(hlt_ylz_d33 != 0){
                                byzStr_b_3 = hlt_ylz_d33+" MPa";
                            }else {
                                byzStr_b_3="";
                            }
                        }else{
                            report.reportStatue = 2; //不合格
                            pressureReport.jl = "本次压力表未进行校验。";
                            //子类状态先设置为0
                            report.failedStart = 1;

                            sczStr_b_1="";
                            sczStr_b_2="";
                            sczStr_b_3="";

                            byzStr_b_1="";
                            byzStr_b_2="";
                            byzStr_b_3="";

                        }
                        //报告的进展  待核验
                        report.reportProgress = 1;
                        report.bsbhHrader = sample.bsbhHrader;
                        report.erweima = sample.erweima;
                        report.wtfId = sample.respirator.wtfId;
                        report.wtf = sample.respirator.wtf;

                        report.wtfIdChi = sample.wtfIdChi;
                        report.wtfChi = sample.wtfChi;

                        report.sjr = sample.sjr;
                        report.zzcsId = sample.zzcsId;
                        report.zzcs = sample.zzcs;

                        report.jyrqNian = TimeUtil.formatTime_Year(datem2.getTime());
                        report.jyrqYue = TimeUtil.formatTime_Month(datem2.getTime());
                        report.zfzddhy = 0;
                        report.jyyId = sample.respirator.jcrId;


                        long year1 = TimeUtil.getDateBeforeYear(TimeUtil.parsex(sample.respirator.sjri), 1);
                        report.xcjyrq = year1;
                        report.setAddTime(TimeUtil.currentTimeMillis());


                        if ("".equals(byzStr_b_1)) {
                            pressureReport.byz1 = "/";
                        } else {
                            pressureReport.byz1 = byzStr_b_1;
                        }

                        if ("".equals(byzStr_b_2)) {
                            pressureReport.byz2 = "/";
                        } else {
                            pressureReport.byz2 = byzStr_b_2;
                        }

                        if ("".equals(byzStr_b_3)) {
                            pressureReport.byz3 = "/";
                        } else {
                            pressureReport.byz3 = byzStr_b_3;
                        }




                        if("".equals(sczStr_b_1)){
                            pressureReport.scz1 = "/";
                        }else{
                            pressureReport.scz1 =sczStr_b_1;
                        }

                        if("".equals(sczStr_b_2)){
                            pressureReport.scz2 = "/";
                        }else{
                            pressureReport.scz2 =sczStr_b_2;
                        }


                        if("".equals(sczStr_b_3)){
                            pressureReport.scz3 = "/";
                        }else{
                            pressureReport.scz3 = sczStr_b_3;
                        }



                        //--------------红蓝图start
                        HltHxqbean hltHxqbean = new HltHxqbean();

                        //面罩泄露测试小于-25Pa 检验结果
                        String mzxlceStrJyjg = "";
                        String mzxlceStrJyjg_hlt ="";
                        //面罩泄露测试小于-25Pa 单项判定
                        String mzxlceStrDxpd = "";

                        //压力表1min 内的下降不大于2Mpa 检验结果
                        String zjqmxStrJyjg = "";
                        //压力表1min 内的下降不大于2Mpa 单项判刑
                        String zjqmxStrDxpd = "";

                        //静态压力 检验结果
                        String jtylStrJyjg = "";
                        //静态压力 单项判定
                        String jtylStrDxpd = "";

                        //报警压力 检验结果
                        String bjyaStrJyjg = "";
                        //报警压力 单项判定
                        String bjyaStrDxpd = "";

                        //报警声强 检验结果
                        String bjsqStrJyjg = "";
                        //报警声强 单项判定
                        String bjsqStrDxpd = "";

                        //压力试验类
                        List<Pressuretests> pressuretestsList = khxinBean.pressuretests;
                        for (Pressuretests pressuretests : pressuretestsList) {
                            if (null != pressuretests.getTesttype()) {
                                switch (pressuretests.getTesttype()) {
                                    case 1:  //面具泄露
                                        if(pressuretests.getPress() != null){
                                            if((pressuretests.getPress()*10)>0){
                                                mzxlceStrJyjg_hlt = "-" + (pressuretests.getPress() * 100 + "Pa");
                                            }else{
                                                mzxlceStrJyjg_hlt = (pressuretests.getPress()* 100 + "Pa");
                                            }
                                            mzxlceStrJyjg="见附页";
                                        }else{
                                            mzxlceStrJyjg ="";
                                        }

                                        if (pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            mzxlceStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            mzxlceStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            mzxlceStrDxpd = "不合格";
                                        }
                                        break;
                                    case 2:  //中压更改
                                        break;
                                    case 3: //中压更改
                                        break;
                                    case 4: //高压力泄露   ---整机气密性
                                        if(null == pressuretests.getPress()){
                                            zjqmxStrJyjg="";
                                        }else{
                                            zjqmxStrJyjg = pressuretests.getPress() / 10 + "";
                                        }
                                        if (null == pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            zjqmxStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            zjqmxStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            zjqmxStrDxpd = "不合格";
                                        }
                                        break;
                                    case 6: //静态面具压力
                                        if(null  == pressuretests.getPress()){
                                            jtylStrJyjg = "";
                                        }else{
                                            float nfnf = pressuretests.getPress() ;
                                            int dede = (int) (nfnf *100) ;
                                            jtylStrJyjg = dede + "Pa";
                                        }
                                        if (null ==pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            jtylStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            jtylStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            jtylStrDxpd = "不合格";
                                        }

                                        break;

                                    case 14: //报警哨
                                        //
                                        if(null == pressuretests.getPress()){
                                            bjyaStrJyjg="";
                                        }else{
                                            bjyaStrJyjg = pressuretests.getPress() / 10 + "MPa";
                                        }
                                        if (null ==pressuretests.getResult() || pressuretests.getResult() == 0 || pressuretests.getResult() == 3) {  // 1：通过  2：失败  3：取消
                                            bjyaStrDxpd = "";
                                        } else if (pressuretests.getResult() == 1) { // 1：通过  2：失败  3：取消
                                            bjyaStrDxpd = "合格";
                                        } else if (pressuretests.getResult() == 2) { // 1：通过  2：失败  3：取消
                                            bjyaStrDxpd = "不合格";
                                        }
                                        break;
                                    case 15: // 振铃
                                        break;

                                }
                            }
                        }

                        //呼吸阻力100L/min  单项判定
                        String hxzl100_dxpd = "";
                        //呼吸阻力100L/min 最小值
                        String hxzl100_x = "";
                        //呼吸阻力100L/min  最大值
                        String hxzl100_d = "";
                        byte[] hxzl100_img;

                        //呼吸阻力50L/min  单项判定
                        String hxzl50_dxpd = "";
                        //呼吸阻力100L/min 最小值
                        String hxzl50_x = "";
                        //呼吸阻力100L/min  最大值
                        String hxzl50_d = "";

                        byte[] hxzl150_img;


                        List<Breathingtests> breathingtests = khxinBean.breathingtests;
                        for (Breathingtests breathingtests1 : breathingtests) {
                            if (breathingtests1.getTesttype() == 9) {
                                if (breathingtests1.getTestorder() == 1) { //呼吸阻力 50L/min
                                    if (breathingtests1.getResult() == 1) { //合格
                                        hxzl50_dxpd = "合格";
                                    } else {  //不合格
                                        hxzl50_dxpd = "不合格";
                                    }
                                    if(null ==breathingtests1.getBmin()){
                                        hxzl50_x="";
                                    }else{
                                        hxzl50_x = ((int)(breathingtests1.getBmin() * 100)) + "";
                                    }

                                    if(null == breathingtests1.getBmax()){
                                        hxzl50_d = "";
                                    }else{
                                        hxzl50_d = ((int)(breathingtests1.getBmax() * 100)) + "";
                                    }
                                    //图片
                                    hxzl150_img = breathingtests1.getGraph();
                                    //if(null != hxzl150_img){
                                    //    boolean isok =  saveImageToLoacl(hxzl150_img,sample.bsbh+"_m50.png");
                                    //    if(isok){
                                    //        report.hltImg1 = "/up/fxq/"+sample.bsbh+"_m50.png";
                                    //    }else{
                                    //        report.hltImg1 ="";
                                    //    }
                                    //}else{
                                    //    report.hltImg1 ="";
                                    //}
                                    if(null != hxzl150_img){
                                        String  zhstr = saveImageToLoacl150(hxzl150_img,sample);
                                        report.hltImg1 = zhstr;
                                    }else{
                                        report.hltImg1 ="";
                                    }

                                } else if (breathingtests1.getTestorder() == 2) {//呼吸阻力 100L/min
                                    if (breathingtests1.getResult() == 1) { //合格
                                        hxzl100_dxpd = "合格";
                                    } else {  //不合格
                                        hxzl100_dxpd = "不合格";
                                    }
                                    if(null ==breathingtests1.getBmin()){
                                        hxzl100_x = "";
                                    }else{
                                        hxzl100_x = ((int)(breathingtests1.getBmin() * 100)) + "";
                                    }

                                    if(null ==breathingtests1.getBmax()){
                                        hxzl100_d ="";
                                    }else{
                                        hxzl100_d = ((int)(breathingtests1.getBmax() * 100)) + "";
                                    }
                                    hxzl100_img = breathingtests1.getGraph();
                                    //if(null != hxzl100_img){
                                    //    boolean isok =  saveImageToLoacl(hxzl100_img,sample.bsbh+"_m100.png");
                                    //    if(isok){
                                    //        report.hltImg2 ="/up/fxq/"+sample.bsbh+"_m100.png";
                                    //    }else{
                                    //        report.hltImg2 ="";
                                    //    }
                                    //}else{
                                    //    report.hltImg2 ="";
                                    //}
                                    if(null != hxzl100_img){
                                        String zhstr100 = saveImageToLoacl100(hxzl100_img,sample);
                                        report.hltImg2 = zhstr100;
                                    }else{
                                        report.hltImg2 ="";
                                    }

                                }
                            }
                        }




                        if(null !=khxinBean.headers && null !=khxinBean.headers.getDatetime()){
                            //测试日期
                            hltHxqbean.hlt_csrq =TimeUtil.formatTime_three(khxinBean.headers.getDatetime().getTime());
                        }
                        //使用单位
                        hltHxqbean. hlt_sydw = sample.respirator.wtf;
                        //制造厂商
                        hltHxqbean.hlt_zzcs = sample.respirator.zzcs;
                        //产品信号
                        hltHxqbean.hlt_cpxh = sample.respirator.xhgg;
                        //产品编号
                        hltHxqbean.hlt_cpbh = sample.bsbh;
                        //整机气密性
                        hltHxqbean.hlt_zjqmx =zjqmxStrDxpd+"    "+zjqmxStrJyjg;
                        //面罩泄露测试
                        hltHxqbean.hlt_mzxlcs =mzxlceStrDxpd+ "  "+mzxlceStrJyjg_hlt;
                        //开启/静压测试
                        hltHxqbean.hlt_kqjycs = jtylStrDxpd+ "   " +jtylStrJyjg;
                        //报警压力测试
                        hltHxqbean.hlt_bjylcs = bjyaStrDxpd+ "   "+bjyaStrJyjg;
                        if(null != khxinBean.gaugetests){
                            Gaugetests gaug =  khxinBean.gaugetests;
                            //压力表校验  合格：不合格
                            hltHxqbean.hlt_ylbjy_str = gaug.getResult() ==1?"合格":"不合格";
                            //实测值1
                            hltHxqbean.hlt_ylz_sc1 = "10 Mpa";
                            //实测值2
                            hltHxqbean.hlt_ylz_sc2 = "15 Mpa";
                            //实测值3
                            hltHxqbean.hlt_ylz_sc3 = "20 Mpa";




                            double hlt_ylz_d11 = ((double)gaug.getPr3()/10);
                            double hlt_ylz_d22 = ((double)gaug.getPr2()/10);
                            double hlt_ylz_d33 = ((double)gaug.getPr1()/10);

                            if(hlt_ylz_d11== 0){
                                //表压值1
                                hltHxqbean.hlt_ylz_by1 = "";
                            }else{
                                //表压值1
                                hltHxqbean.hlt_ylz_by1 = df.format(hlt_ylz_d11)+"Mpa";
                            }

                            if(hlt_ylz_d22== 0){
                                //表压值2
                                hltHxqbean.hlt_ylz_by2 = "";
                            }else{
                                //表压值2
                                hltHxqbean.hlt_ylz_by2 = df.format(hlt_ylz_d22)+"Mpa";
                            }

                            if(hlt_ylz_d33 == 0){
                                //表压值3
                                hltHxqbean.hlt_ylz_by3 = "";
                            }else{
                                //表压值3
                                hltHxqbean.hlt_ylz_by3 = df.format(hlt_ylz_d33)+"Mpa";
                            }

                            //呼吸阻力50L/min
                            hltHxqbean.hlt_zl50_x =hxzl50_x;
                            hltHxqbean.hlt_zl50_d=  hxzl50_d;
                            hltHxqbean.hlt_zl50_jg = hxzl50_dxpd;
                            //呼吸阻力100L/min
                            hltHxqbean.hlt_zl100_x = hxzl100_x;
                            hltHxqbean.hlt_zl100_d = hxzl100_d;
                            hltHxqbean.hlt_zl100_jg = hxzl100_dxpd;
                        }

                        if(null != khxinBean.visualtests){
                            Visualtests vv=  khxinBean.visualtests;
                            if(vv.getFacepiece() == 1){
                                hltHxqbean.ms_mz ="合格";
                            }else if(vv.getFacepiece() == 2){
                                hltHxqbean.ms_mz ="不合格";
                            }else{
                                hltHxqbean.ms_mz ="";
                            }


                            if(vv.getCarrier() == 1){
                                hltHxqbean.ms_bjsd ="合格";
                            } else if(vv.getCarrier() == 2){
                                hltHxqbean.ms_bjsd ="不合格";
                            }else{
                                hltHxqbean.ms_bjsd ="";
                            }

                            if(vv.getCylinder() == 1){
                                hltHxqbean.ms_qp ="合格";
                            } else if(vv.getCylinder() == 2){
                                hltHxqbean.ms_qp ="不合格";
                            }else{
                                hltHxqbean.ms_qp ="";
                            }

                            if(vv.getWarning() == 1){
                                hltHxqbean.ms_dyljg ="合格";
                            } else if(vv.getWarning() == 2){
                                hltHxqbean.ms_dyljg ="不合格";
                            }else{
                                hltHxqbean.ms_dyljg ="";
                            }
                            if(vv.getHoses() == 1){
                                hltHxqbean.ms_jg ="合格";
                            } else if(vv.getHoses() == 2){
                                hltHxqbean.ms_jg ="不合格";
                            }else{
                                hltHxqbean.ms_jg ="";
                            }

                        }

                        if(null !=khxinBean.headers){
                            //测试人员
                            String hlt_csry =khxinBean.headers.getUsername();
                            hltHxqbean.hlt_csry = hlt_csry;
                        }
                        pressureReport.khxinBean= hltHxqbean;
                        //--------------红蓝图end

                        if(null!=mOtherInput){
                            //检验单位授权号
                            pressureReport.jydwsqh = mOtherInput.ylb_jydwsqh;
                        }else{
                            //检验单位授权号
                            pressureReport.jydwsqh = Config.YLB_JTDWSQH;
                        }
                        pressureReport.jyyId = sample.respirator.jcrId;
                        pressureReport.jyy = sample.respirator.jcr;
                        pressureReport.jyrq = sample.respirator.sjri;
                        //获取测试日期 2020/1/3 15:03:02
                        Date bgcerqStr =khxinBean.headers.getDatetime();
                        //报告的测试日期
                        pressureReport.bgCsrq = bgcerqStr.getTime();
                        report.pressure = pressureReport;
                        reportDao.save(report);
                    }
                }

                // -------------------------------------------------------------------压力表end-------------------

            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return resultMsg;
    }


    public String   saveImageToLoacl150(byte[] hxzl150_img,Sample sample){
        String mstr="";
        try{
            BASE64Decoder decoder = new BASE64Decoder();
            OutputStream os = new FileOutputStream(Config.UPLOADFOLDER3+"/"+sample.bsbh+"_m50.png");
            //OutputStream os = new FileOutputStream(Config.UPLOADFOLDER3+"\\"+sample.bsbh+"_m50.png");
            os.write(hxzl150_img, 0, hxzl150_img.length);
            os.flush();
            os.close();
            mstr  = "/hxq/"+sample.bsbh+"_m50.png";
            //mstr  = "\\hxq\\"+sample.bsbh+"_m50.png";
        }catch (Exception e){
            mstr = "";
        }
        return mstr;
    }


    public String   saveImageToLoacl100(byte[] hxzl100_img,Sample sample){
        String mstr="";
        try{
            BASE64Decoder decoder = new BASE64Decoder();
            OutputStream os = new FileOutputStream(Config.UPLOADFOLDER3+"/"+sample.bsbh+"_m100.png");
            //OutputStream os = new FileOutputStream(Config.UPLOADFOLDER3+"\\"+sample.bsbh+"_m100.png");
            os.write(hxzl100_img, 0, hxzl100_img.length);
            os.flush();
            os.close();
            mstr = "/hxq/"+sample.bsbh+"_m100.png";
            //mstr = "\\hxq\\"+sample.bsbh+"_m100.png";
        }catch (Exception e){
            mstr = "";
        }
        return mstr;
    }



    public String saveImageToLoacl2(byte[] hxzl100_img,String manme){
        String mstr="";
        try{
            BASE64Decoder decoder = new BASE64Decoder();
            OutputStream os = new FileOutputStream(Config.UPLOADFOLDER3+"/"+manme);
            //OutputStream os = new FileOutputStream(Config.UPLOADFOLDER3+"\\"+sample.bsbh+"_m100.png");
            os.write(hxzl100_img, 0, hxzl100_img.length);
            os.flush();
            os.close();
            mstr = "/hxq/"+manme+"_m100.png";
            //mstr = "\\hxq\\"+sample.bsbh+"_m100.png";
        }catch (Exception e){
            mstr = "";
        }
        return mstr;
    }

}
